public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init()
@ 2025-12-17 14:21 Wentao Liang
  2026-01-05  9:27 ` Andreas Kemnade
  2026-01-05 20:15 ` Kevin Hilman
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2025-12-17 14:21 UTC (permalink / raw)
  To: aaro.koskinen, andreas, khilman, rogerq, tony, linux
  Cc: linux-arm-kernel, linux-omap, linux-kernel, Wentao Liang, stable

The of_get_child_by_name() function increments the reference count
of child nodes, causing multiple reference leaks in omap_control_init():

1. scm_conf node never released in normal/error paths
2. clocks node leak when checking existence
3. Missing scm_conf release before np in error paths

Fix these leaks by adding proper of_node_put() calls and separate error
handling.

Fixes: e5b635742e98 ("ARM: OMAP2+: control: add syscon support for register accesses")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 arch/arm/mach-omap2/control.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 79860b23030d..eb6fc7c61b6e 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -732,7 +732,7 @@ int __init omap2_control_base_init(void)
  */
 int __init omap_control_init(void)
 {
-	struct device_node *np, *scm_conf;
+	struct device_node *np, *scm_conf, *clocks_node;
 	const struct of_device_id *match;
 	const struct omap_prcm_init_data *data;
 	int ret;
@@ -753,16 +753,19 @@ int __init omap_control_init(void)
 
 			if (IS_ERR(syscon)) {
 				ret = PTR_ERR(syscon);
-				goto of_node_put;
+				goto err_put_scm_conf;
 			}
 
-			if (of_get_child_by_name(scm_conf, "clocks")) {
+			clocks_node = of_get_child_by_name(scm_conf, "clocks");
+			if (clocks_node) {
+				of_node_put(clocks_node);
 				ret = omap2_clk_provider_init(scm_conf,
 							      data->index,
 							      syscon, NULL);
 				if (ret)
-					goto of_node_put;
+					goto err_put_scm_conf;
 			}
+			of_node_put(scm_conf);
 		} else {
 			/* No scm_conf found, direct access */
 			ret = omap2_clk_provider_init(np, data->index, NULL,
@@ -780,6 +783,9 @@ int __init omap_control_init(void)
 
 	return 0;
 
+err_put_scm_conf:
+	if (scm_conf)
+		of_node_put(scm_conf);
 of_node_put:
 	of_node_put(np);
 	return ret;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init()
  2025-12-17 14:21 [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init() Wentao Liang
@ 2026-01-05  9:27 ` Andreas Kemnade
  2026-01-05 20:15 ` Kevin Hilman
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Kemnade @ 2026-01-05  9:27 UTC (permalink / raw)
  To: Wentao Liang
  Cc: aaro.koskinen, khilman, rogerq, tony, linux, linux-arm-kernel,
	linux-omap, linux-kernel, stable

On Wed, 17 Dec 2025 14:21:22 +0000
Wentao Liang <vulab@iscas.ac.cn> wrote:

> The of_get_child_by_name() function increments the reference count
> of child nodes, causing multiple reference leaks in omap_control_init():
> 
> 1. scm_conf node never released in normal/error paths
> 2. clocks node leak when checking existence
> 3. Missing scm_conf release before np in error paths
> 
> Fix these leaks by adding proper of_node_put() calls and separate error
> handling.
> 
> Fixes: e5b635742e98 ("ARM: OMAP2+: control: add syscon support for register accesses")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init()
  2025-12-17 14:21 [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init() Wentao Liang
  2026-01-05  9:27 ` Andreas Kemnade
@ 2026-01-05 20:15 ` Kevin Hilman
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Hilman @ 2026-01-05 20:15 UTC (permalink / raw)
  To: aaro.koskinen, andreas, rogerq, tony, linux, Wentao Liang
  Cc: linux-arm-kernel, linux-omap, linux-kernel, stable


On Wed, 17 Dec 2025 14:21:22 +0000, Wentao Liang wrote:
> The of_get_child_by_name() function increments the reference count
> of child nodes, causing multiple reference leaks in omap_control_init():
> 
> 1. scm_conf node never released in normal/error paths
> 2. clocks node leak when checking existence
> 3. Missing scm_conf release before np in error paths
> 
> [...]

Applied, thanks!

[1/1] ARM: omap2: Fix reference count leaks in omap_control_init()
      commit: 93a04ab480c8bbcb7d9004be139c538c8a0c1bc8

Best regards,
-- 
Kevin Hilman <khilman@baylibre.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-05 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 14:21 [PATCH] ARM: omap2: Fix reference count leaks in omap_control_init() Wentao Liang
2026-01-05  9:27 ` Andreas Kemnade
2026-01-05 20:15 ` Kevin Hilman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox