Skip to content

Commit 93a04ab

Browse files
ISCAS-Vulabkhilman
authored andcommitted
ARM: omap2: Fix reference count leaks in omap_control_init()
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: e5b6357 ("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> Link: https://patch.msgid.link/20251217142122.1861292-1-vulab@iscas.ac.cn Signed-off-by: Kevin Hilman <khilman@baylibre.com>
1 parent 8f0b4cc commit 93a04ab

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

arch/arm/mach-omap2/control.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ int __init omap2_control_base_init(void)
732732
*/
733733
int __init omap_control_init(void)
734734
{
735-
struct device_node *np, *scm_conf;
735+
struct device_node *np, *scm_conf, *clocks_node;
736736
const struct of_device_id *match;
737737
const struct omap_prcm_init_data *data;
738738
int ret;
@@ -753,16 +753,19 @@ int __init omap_control_init(void)
753753

754754
if (IS_ERR(syscon)) {
755755
ret = PTR_ERR(syscon);
756-
goto of_node_put;
756+
goto err_put_scm_conf;
757757
}
758758

759-
if (of_get_child_by_name(scm_conf, "clocks")) {
759+
clocks_node = of_get_child_by_name(scm_conf, "clocks");
760+
if (clocks_node) {
761+
of_node_put(clocks_node);
760762
ret = omap2_clk_provider_init(scm_conf,
761763
data->index,
762764
syscon, NULL);
763765
if (ret)
764-
goto of_node_put;
766+
goto err_put_scm_conf;
765767
}
768+
of_node_put(scm_conf);
766769
} else {
767770
/* No scm_conf found, direct access */
768771
ret = omap2_clk_provider_init(np, data->index, NULL,
@@ -780,6 +783,9 @@ int __init omap_control_init(void)
780783

781784
return 0;
782785

786+
err_put_scm_conf:
787+
if (scm_conf)
788+
of_node_put(scm_conf);
783789
of_node_put:
784790
of_node_put(np);
785791
return ret;

0 commit comments

Comments
 (0)