Skip to contentSkip to conversation

ARM: OMAP2+: Fix refcount leak in omapdss_init_of

PATCH Superseded Miaoqian Lin 3 participants 3 messages Jun 1, 2022 – Jun 28, 2022

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

PATCH 1/1 ARM: OMAP2+: Fix refcount leak in omapdss_init_of

omapdss_find_dss_of_node() calls of_find_compatible_node() to get device node. of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() in later error path and normal path.

Fixes e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
---
 arch/arm/mach-omap2/display.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-omap2/display.c +2 -0
index 21413a9b7b6c..ed2cb2649cf6 100644
@@ -259,11 +259,13 @@ static int __init omapdss_init_of(void)
 
 	if (!pdev) {
 		pr_err("Unable to find DSS platform device\n");
+		of_node_put(node);
 		return -ENODEV;
 	}
 
 	r = of_platform_populate(node, NULL, NULL, &pdev->dev);
 	put_device(&pdev->dev);
+	of_node_put(node);
 	if (r) {
 		pr_err("Unable to populate DSS submodule devices\n");
 		return r;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Hello Lin,

Thank you for the patch.

Quoted 7 lines · Miaoqian Lin

omapdss_find_dss_of_node() calls of_find_compatible_node() to get device node. of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() in later error path and normal path.

Fixes e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")
Quoted 22 lines
---
 arch/arm/mach-omap2/display.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-omap2/display.c +2 -0
index 21413a9b7b6c..ed2cb2649cf6 100644
@@ -259,11 +259,13 @@ static int __init omapdss_init_of(void)
 
 	if (!pdev) {
 		pr_err("Unable to find DSS platform device\n");
+		of_node_put(node);
 		return -ENODEV;
 	}
 
 	r = of_platform_populate(node, NULL, NULL, &pdev->dev);
 	put_device(&pdev->dev);
+	of_node_put(node);
 	if (r) {
 		pr_err("Unable to populate DSS submodule devices\n");
 		return r;
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer
#2 lore raw
Quoted 10 lines · Laurent Pinchart

Hello Lin,

Thank you for the patch.

Quoted 5 lines · Miaoqian Lin

omapdss_find_dss_of_node() calls of_find_compatible_node() to get device node. of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() in later error path and normal path.

Quoted 4 lines
Quoted 2 lines
Fixes e0c827aca0730 ("drm/omap: Populate DSS children in omapdss driver")

Thanks applying this into omap-for-v5.20/soc.

Regards,

Tony