lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241021190150.5974-1-liujing@cmss.chinamobile.com>
Date: Tue, 22 Oct 2024 03:01:50 +0800
From: Liu Jing <liujing@...s.chinamobile.com>
To: kbusch@...nel.org
Cc: axboe@...nel.dk,
	hch@....de,
	sagi@...mberg.me,
	linux-nvme@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Liu Jing <liujing@...s.chinamobile.com>
Subject: [PATCH] nvme-pci: After the memory is released, the corresponding pointer needs to point to empty

The code frees memory pointed to by dev->queues. After freeing memory,
dev->queues should be set to NULL to avoid dangling Pointers.

Signed-off-by: Liu Jing <liujing@...s.chinamobile.com>
---
 drivers/nvme/host/pci.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 1cbff7537788..c1500c00f571 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2731,7 +2731,9 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
 	nvme_free_tagset(dev);
 	put_device(dev->dev);
 	kfree(dev->queues);
+	dev->queues = NULL;
 	kfree(dev);
+	dev = NULL;
 }
 
 static void nvme_reset_work(struct work_struct *work)
@@ -3055,8 +3057,10 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev,
 out_put_device:
 	put_device(dev->dev);
 	kfree(dev->queues);
+	dev->queues = NULL;
 out_free_dev:
 	kfree(dev);
+	dev = NULL;
 	return ERR_PTR(ret);
 }
 
-- 
2.27.0




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ