[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221123134527.119441-1-xiujianfeng@huawei.com>
Date: Wed, 23 Nov 2022 21:45:27 +0800
From: Xiu Jianfeng <xiujianfeng@...wei.com>
To: <oohall@...il.com>, <dan.j.williams@...el.com>,
<vishal.l.verma@...el.com>, <dave.jiang@...el.com>,
<ira.weiny@...el.com>, <aneesh.kumar@...ux.ibm.com>
CC: <nvdimm@...ts.linux.dev>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] libnvdimm/of_pmem: Fix memory leak in of_pmem_region_probe()
After changes in commit 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique
name for bus provider"), @priv->bus_desc.provider_name is no longer a
const string, but a dynamic string allocated by kstrdup(), it should be
freed on the error path, and when driver is removed.
Fixes: 49bddc73d15c ("libnvdimm/of_pmem: Provide a unique name for bus provider")
Signed-off-by: Xiu Jianfeng <xiujianfeng@...wei.com>
---
drivers/nvdimm/of_pmem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
index 10dbdcdfb9ce..1292ffca7b2e 100644
--- a/drivers/nvdimm/of_pmem.c
+++ b/drivers/nvdimm/of_pmem.c
@@ -36,6 +36,7 @@ static int of_pmem_region_probe(struct platform_device *pdev)
priv->bus = bus = nvdimm_bus_register(&pdev->dev, &priv->bus_desc);
if (!bus) {
+ kfree(priv->bus_desc.provider_name);
kfree(priv);
return -ENODEV;
}
@@ -83,6 +84,7 @@ static int of_pmem_region_remove(struct platform_device *pdev)
struct of_pmem_private *priv = platform_get_drvdata(pdev);
nvdimm_bus_unregister(priv->bus);
+ kfree(priv->bus_desc.provider_name);
kfree(priv);
return 0;
--
2.17.1
Powered by blists - more mailing lists