Fwd: [PATCH] nvme-pci: fixing memory leak in probe teardown path

irvin cote irvincoteg at gmail.com
Mon Feb 27 08:07:38 PST 2023


---------- Forwarded message ---------
From: Irvin Cote <irvincoteg at gmail.com>
Date: Fri, 24 Feb 2023 at 22:38
Subject: [PATCH] nvme-pci: fixing memory leak in probe teardown path
To: <kbusch at kernel.org>
Cc: <axboe at fb.com>, <hch at lst.de>, <sagi at grimberg.me>


In case the nvme_probe teardown path is triggered the ctrl ref count
does not reach 0 thus creating a memory leak upon failure of nvme_probe

Signed-off-by: Irvin Cote <irvincoteg at gmail.com>
---
 drivers/nvme/host/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 5b95c94ee40f..0b61caf6be67 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3072,6 +3072,7 @@ static int nvme_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
 out_dev_unmap:
        nvme_dev_unmap(dev);
 out_uninit_ctrl:
+       nvme_put_ctrl(&dev->ctrl);
        nvme_uninit_ctrl(&dev->ctrl);
        return result;
 }
--
2.37.2



More information about the Linux-nvme mailing list