Commit de65e642 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

nvme-pci: use struct_size for allocation struct nvme_dev



This avoids open coding the variable size array arithmetics.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarKanchan Joshi <joshi.k@samsung.com>
Reviewed-by: default avatarCaleb Sander Mateos <csander@purestorage.com>
Reviewed-by: default avatarLeon Romanovsky <leon@kernel.org>
parent f01e389e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3212,8 +3212,8 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
	struct nvme_dev *dev;
	int ret = -ENOMEM;

	dev = kzalloc_node(sizeof(*dev) + nr_node_ids *
			sizeof(*dev->descriptor_pools), GFP_KERNEL, node);
	dev = kzalloc_node(struct_size(dev, descriptor_pools, nr_node_ids),
			GFP_KERNEL, node);
	if (!dev)
		return ERR_PTR(-ENOMEM);
	INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work);