Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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>
Link: https://patch.msgid.link/20251217142122.1861292-1-vulab@iscas.ac.cn
Signed-off-by: Kevin Hilman <khilman@baylibre.com>

authored by

Wentao Liang and committed by
Kevin Hilman
93a04ab4 8f0b4cce

+10 -4
+10 -4
arch/arm/mach-omap2/control.c
··· 732 732 */ 733 733 int __init omap_control_init(void) 734 734 { 735 - struct device_node *np, *scm_conf; 735 + struct device_node *np, *scm_conf, *clocks_node; 736 736 const struct of_device_id *match; 737 737 const struct omap_prcm_init_data *data; 738 738 int ret; ··· 753 753 754 754 if (IS_ERR(syscon)) { 755 755 ret = PTR_ERR(syscon); 756 - goto of_node_put; 756 + goto err_put_scm_conf; 757 757 } 758 758 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); 760 762 ret = omap2_clk_provider_init(scm_conf, 761 763 data->index, 762 764 syscon, NULL); 763 765 if (ret) 764 - goto of_node_put; 766 + goto err_put_scm_conf; 765 767 } 768 + of_node_put(scm_conf); 766 769 } else { 767 770 /* No scm_conf found, direct access */ 768 771 ret = omap2_clk_provider_init(np, data->index, NULL, ··· 783 780 784 781 return 0; 785 782 783 + err_put_scm_conf: 784 + if (scm_conf) 785 + of_node_put(scm_conf); 786 786 of_node_put: 787 787 of_node_put(np); 788 788 return ret;