[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200818031556.2921-3-thunder.leizhen@huawei.com>
Date: Tue, 18 Aug 2020 11:15:55 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Oliver O'Halloran <oohall@...il.com>,
Dan Williams <dan.j.williams@...el.com>,
Vishal Verma <vishal.l.verma@...el.com>,
"Dave Jiang" <dave.jiang@...el.com>,
Ira Weiny <ira.weiny@...el.com>,
linux-nvdimm <linux-nvdimm@...ts.01.org>,
linux-kernel <linux-kernel@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 2/3] libnvdimm: add sanity check for provider_name in of_pmem_region_probe()
kstrdup() may return NULL because of no memory, check it.
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
drivers/nvdimm/of_pmem.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 1292ffca7b2ecc0..13c4c274ca6ea88 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -31,6 +31,11 @@ static int of_pmem_region_probe(struct platform_device *pdev)
return -ENOMEM;
priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
+ if (!priv->bus_desc.provider_name) {
+ kfree(priv);
+ return -ENOMEM;
+ }
+
priv->bus_desc.module = THIS_MODULE;
priv->bus_desc.of_node = np;
--
1.8.3
Powered by blists - more mailing lists