summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIrvin Cote <irvin.cote@insa-lyon.fr>2023-02-09 17:43:57 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-06 13:18:20 +0200
commit9690ad557d9472a024f26a5f2980006c652e9b3f (patch)
tree71af382045d5ff47a65f45939cbfdcf901334e6c
parent3c29c6e8cd7cb83d9d2bbd3f51c6840112deb842 (diff)
downloadlinux-9690ad557d9472a024f26a5f2980006c652e9b3f.tar.gz
linux-9690ad557d9472a024f26a5f2980006c652e9b3f.tar.bz2
linux-9690ad557d9472a024f26a5f2980006c652e9b3f.zip
nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev
[ Upstream commit dc785d69d753a3894c93afc23b91404652382ead ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/nvme/host/pci.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index e5980df2094a..65172a654a19 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2977,7 +2977,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);
INIT_WORK(&dev->remove_work, nvme_remove_dead_ctrl_work);
mutex_init(&dev->shutdown_lock);
@@ -3022,8 +3022,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)