From: Irvin Cote Date: Thu, 9 Feb 2023 20:43:57 +0000 (-0300) Subject: nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev X-Git-Tag: v6.6-pxa1908~1949^2^2 X-Git-Url: https://git.dujemihanovic.xyz/?a=commitdiff_plain;h=dc785d69d753a3894c93afc23b91404652382ead;p=linux.git nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev Don't mix NULL and ERR_PTR returns. Fixes: 2e87570be9d2 ("nvme-pci: factor out a nvme_pci_alloc_dev helper") Signed-off-by: Irvin Cote Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index b1ceb1032784..6d88ddd35565 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2964,7 +2964,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, dev = kzalloc_node(sizeof(*dev), GFP_KERNEL, node); if (!dev) - return NULL; + return ERR_PTR(-ENOMEM); INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work); mutex_init(&dev->shutdown_lock); @@ -3029,8 +3029,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) int result = -ENOMEM; dev = nvme_pci_alloc_dev(pdev, id); - if (!dev) - return -ENOMEM; + if (IS_ERR(dev)) + return PTR_ERR(dev); result = nvme_dev_map(dev); if (result)