]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev
authorIrvin Cote <irvin.cote@insa-lyon.fr>
Thu, 9 Feb 2023 20:43:57 +0000 (17:43 -0300)
committerChristoph Hellwig <hch@lst.de>
Tue, 14 Feb 2023 05:39:02 +0000 (06:39 +0100)
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 <irvin.cote@insa-lyon.fr>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/pci.c

index b1ceb103278441a3f0024db32236cdac3408b829..6d88ddd355657094dc581364cc4dd38380f912a5 100644 (file)
@@ -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)