libnvdimm/of_pmem: Fix leaking bus_desc.provider_name in some paths
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().
--- drivers/nvdimm/of_pmem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvdimm/of_pmem.c +2 -0
@@ -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
Quoted 8 lines · Vaibhav Jain
String 'bus_desc.provider_name' allocated inside
of_pmem_region_probe()will leak in case call tonvdimm_bus_register()fails or whenof_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 inof_pmem_region_remove().
Quoted 32 lines
Fixes 49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider")Signed-off-by Vaibhav Jain <[email protected]>--- drivers/nvdimm/of_pmem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/nvdimm/of_pmem.c +2
-0@@ -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]
Quoted 28 lines · Vaibhav Jain
String 'bus_desc.provider_name' allocated inside
of_pmem_region_probe()will leak in case call tonvdimm_bus_register()fails or whenof_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 inof_pmem_region_remove().Fixes 49bddc73d15c2("libnvdimm/of_pmem: Provide a unique name for bus provider")Signed-off-by Vaibhav Jain <[email protected]>--- drivers/nvdimm/of_pmem.c | 2 ++ 1 file changed, 2 insertions(+)drivers/nvdimm/of_pmem.c +1
-0@@ -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]