Skip to contentSkip to conversation

libnvdimm/of_pmem: Fix leaking bus_desc.provider_name in some paths

PATCH In review Vaibhav Jain 3 participants 3 messages Jan 23, 2020 – Feb 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnvdimm/of_pmem: Fix leaking bus_desc.provider_name in some paths

String 'bus_desc.provider_name' allocated inside of_pmem_region_probe() will leak in case call to nvdimm_bus_register() fails or when of_pmem_region_remove() is called.

This minor patch ensures that 'bus_desc.provider_name' is freed in error path for of_pmem_region_probe() as well as in of_pmem_region_remove().

Fixes 49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider")
---
 drivers/nvdimm/of_pmem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvdimm/of_pmem.c +2 -0
index 8224d1431ea9..9cb76f9837ad 100644
@@ -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;
 	}
@@ -81,6 +82,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;
Signature · 1 line
2.24.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vaibhav Jain

String 'bus_desc.provider_name' allocated inside of_pmem_region_probe() will leak in case call to nvdimm_bus_register() fails or when of_pmem_region_remove() is called.

This minor patch ensures that 'bus_desc.provider_name' is freed in error path for of_pmem_region_probe() as well as in of_pmem_region_remove().

Quoted 32 lines
Fixes 49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider")
---
 drivers/nvdimm/of_pmem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvdimm/of_pmem.c +2 -0
index 8224d1431ea9..9cb76f9837ad 100644
@@ -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;
 	}
@@ -81,6 +82,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;
Signature · 4 lines
2.24.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

Reviewed-by on v1 1/1
#2 lore raw
In reply to Vaibhav Jain
Quoted 28 lines · Vaibhav Jain

String 'bus_desc.provider_name' allocated inside of_pmem_region_probe() will leak in case call to nvdimm_bus_register() fails or when of_pmem_region_remove() is called.

This minor patch ensures that 'bus_desc.provider_name' is freed in error path for of_pmem_region_probe() as well as in of_pmem_region_remove().

Fixes 49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider")
---
 drivers/nvdimm/of_pmem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvdimm/of_pmem.c +1 -0
index 8224d1431ea9..9cb76f9837ad 100644
@@ -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;
 	}

drivers/nvdimm/of_pmem.c static int of_pmem_region_remove(struct platform_device *pdev) · line 88

Quoted 7 lines
drivers/nvdimm/of_pmem.c +1 -0
@@ -81,6 +82,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;

_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]