NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
* [PATCH] nvdimm: fix possible null-ptr-deref in nd_dax_probe()
@ 2024-10-26  1:06 Yi Yang
  2024-10-28 14:17 ` Ira Weiny
  2024-10-28 16:26 ` Dan Williams
  0 siblings, 2 replies; 7+ messages in thread
From: Yi Yang @ 2024-10-26  1:06 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny
  Cc: nvdimm, wangweiyang2

It will cause null-ptr-deref when nd_dax_alloc() returns NULL, fix it by
add check for nd_dax_alloc().

Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support")
Signed-off-by: Yi Yang <yiyang13@huawei.com>
---
 drivers/nvdimm/dax_devs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
index 6b4922de3047..70a7e401f90d 100644
--- a/drivers/nvdimm/dax_devs.c
+++ b/drivers/nvdimm/dax_devs.c
@@ -106,6 +106,10 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns)
 
 	nvdimm_bus_lock(&ndns->dev);
 	nd_dax = nd_dax_alloc(nd_region);
+	if (!nd_dax) {
+		nvdimm_bus_unlock(&ndns->dev);
+		return -ENOMEM;
+	}
 	nd_pfn = &nd_dax->nd_pfn;
 	dax_dev = nd_pfn_devinit(nd_pfn, ndns);
 	nvdimm_bus_unlock(&ndns->dev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-13 17:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26  1:06 [PATCH] nvdimm: fix possible null-ptr-deref in nd_dax_probe() Yi Yang
2024-10-28 14:17 ` Ira Weiny
2024-10-29  2:10   ` yiyang (D)
2024-10-28 16:26 ` Dan Williams
2024-10-29  1:57   ` yiyang (D)
2024-11-08  8:55   ` [PATCH] nvdimm: rectify the illogical code within nd_dax_probe() Yi Yang
2024-11-13 17:08     ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox