Commit 6fd4ebfc authored by Chen Ni's avatar Chen Ni Committed by Ira Weiny

libnvdimm/of_pmem: Use devm_kstrdup instead of kstrdup and check its return value

Use devm_kstrdup() instead of kstrdup() and check its return value to
avoid memory leak.

Fixes: 49bddc73 ("libnvdimm/of_pmem: Provide a unique name for bus provider")
Signed-off-by: default avatarChen Ni <nichen@iscas.ac.cn>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Signed-off-by: default avatarIra Weiny <ira.weiny@intel.com>
parent 75b3d5dc
......@@ -30,7 +30,13 @@ static int of_pmem_region_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
priv->bus_desc.provider_name = kstrdup(pdev->name, GFP_KERNEL);
priv->bus_desc.provider_name = devm_kstrdup(&pdev->dev, 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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment