From 93a04ab480c8bbcb7d9004be139c538c8a0c1bc8 Mon Sep 17 00:00:00 2001 From: Wentao Liang Date: Wed, 17 Dec 2025 14:21:22 +0000 Subject: [PATCH 1/4] 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 Reviewed-by: Andreas Kemnade Link: https://patch.msgid.link/20251217142122.1861292-1-vulab@iscas.ac.cn Signed-off-by: Kevin Hilman --- 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; From dc717e24deb4e626f4ad4896dd722815ef32311a Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 29 Dec 2025 21:52:30 -0800 Subject: [PATCH 2/4] ARM: omap1: drop unused Kconfig symbol "select ARCH_HAS_HOLES_MEMORYMODEL" was mistakenly merged here due to a botched rebase (says Arnd [1]). Drop that line since that symbol is not used anywhere else in the kernel source tree. [1] https://lore.kernel.org/all/5e335232-89b4-4c35-93bd-efad7e4d8995@app.fastmail.com/ Fixes: 7036440eab3e ("ARM: omap1: enable multiplatform") Signed-off-by: Randy Dunlap Reviewed-by: Aaro Koskinen Link: https://patch.msgid.link/20251230055230.3212260-1-rdunlap@infradead.org Signed-off-by: Kevin Hilman --- arch/arm/mach-omap1/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig index 08ec6bd84ada..b114f7ca2173 100644 --- a/arch/arm/mach-omap1/Kconfig +++ b/arch/arm/mach-omap1/Kconfig @@ -4,7 +4,6 @@ menuconfig ARCH_OMAP1 depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 depends on CPU_LITTLE_ENDIAN depends on ATAGS - select ARCH_HAS_HOLES_MEMORYMODEL select ARCH_OMAP select CLKSRC_MMIO select FORCE_PCI if PCCARD From ef45b853ed8c3a904eaeeccea02b8c2c49891955 Mon Sep 17 00:00:00 2001 From: "Rob Herring (Arm)" Date: Mon, 5 Jan 2026 15:06:44 -0600 Subject: [PATCH 3/4] ARM: at91: Move PM init functions to .init_late hook Move the AT91 PM init functions to .init_late hook to ensure driver dependencies have probed. Acked-by: Alexandre Belloni Tested-by: Alexandre Belloni Signed-off-by: Rob Herring (Arm) Link: https://lore.kernel.org/r/20260105-at91-probe-v3-2-594013ff2965@kernel.org Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/at91rm9200.c | 3 +-- arch/arm/mach-at91/at91sam9.c | 3 +-- arch/arm/mach-at91/sam9x60.c | 3 +-- arch/arm/mach-at91/sam9x7.c | 3 +-- arch/arm/mach-at91/sama5.c | 5 +++-- arch/arm/mach-at91/sama7.c | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 4f8186211619..2ac564eb8bbb 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c @@ -17,8 +17,6 @@ static void __init at91rm9200_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); - - at91rm9200_pm_init(); } static const char *const at91rm9200_dt_board_compat[] __initconst = { @@ -27,6 +25,7 @@ static const char *const at91rm9200_dt_board_compat[] __initconst = { }; DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200") + .init_late = at91rm9200_pm_init, .init_machine = at91rm9200_dt_device_init, .dt_compat = at91rm9200_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c index 7e572189a5eb..cf07cba4ee5d 100644 --- a/arch/arm/mach-at91/at91sam9.c +++ b/arch/arm/mach-at91/at91sam9.c @@ -17,8 +17,6 @@ static void __init at91sam9_init(void) { of_platform_default_populate(NULL, NULL, NULL); - - at91sam9_pm_init(); } static const char *const at91_dt_board_compat[] __initconst = { @@ -28,6 +26,7 @@ static const char *const at91_dt_board_compat[] __initconst = { DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM9") /* Maintainer: Atmel */ + .init_late = at91sam9_pm_init, .init_machine = at91sam9_init, .dt_compat = at91_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sam9x60.c b/arch/arm/mach-at91/sam9x60.c index d8c739d25458..a31beaaeffcd 100644 --- a/arch/arm/mach-at91/sam9x60.c +++ b/arch/arm/mach-at91/sam9x60.c @@ -18,8 +18,6 @@ static void __init sam9x60_init(void) { of_platform_default_populate(NULL, NULL, NULL); - - sam9x60_pm_init(); } static const char *const sam9x60_dt_board_compat[] __initconst = { @@ -29,6 +27,7 @@ static const char *const sam9x60_dt_board_compat[] __initconst = { DT_MACHINE_START(sam9x60_dt, "Microchip SAM9X60") /* Maintainer: Microchip */ + .init_late = sam9x60_pm_init, .init_machine = sam9x60_init, .dt_compat = sam9x60_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sam9x7.c b/arch/arm/mach-at91/sam9x7.c index e1ff30b5b09b..0c73f7fefd4f 100644 --- a/arch/arm/mach-at91/sam9x7.c +++ b/arch/arm/mach-at91/sam9x7.c @@ -17,8 +17,6 @@ static void __init sam9x7_init(void) { of_platform_default_populate(NULL, NULL, NULL); - - sam9x7_pm_init(); } static const char * const sam9x7_dt_board_compat[] __initconst = { @@ -28,6 +26,7 @@ static const char * const sam9x7_dt_board_compat[] __initconst = { DT_MACHINE_START(sam9x7_dt, "Microchip SAM9X7") /* Maintainer: Microchip */ + .init_late = sam9x7_pm_init, .init_machine = sam9x7_init, .dt_compat = sam9x7_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sama5.c b/arch/arm/mach-at91/sama5.c index bf2b5c6a18c6..576654cba82d 100644 --- a/arch/arm/mach-at91/sama5.c +++ b/arch/arm/mach-at91/sama5.c @@ -33,7 +33,6 @@ static void __init sama5_secure_cache_init(void) static void __init sama5_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sama5_pm_init(); } static const char *const sama5_dt_board_compat[] __initconst = { @@ -43,6 +42,7 @@ static const char *const sama5_dt_board_compat[] __initconst = { DT_MACHINE_START(sama5_dt, "Atmel SAMA5") /* Maintainer: Atmel */ + .init_late = sama5_pm_init, .init_machine = sama5_dt_device_init, .dt_compat = sama5_dt_board_compat, MACHINE_END @@ -55,6 +55,7 @@ static const char *const sama5_alt_dt_board_compat[] __initconst = { DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5") /* Maintainer: Atmel */ .init_machine = sama5_dt_device_init, + .init_late = sama5_pm_init, .dt_compat = sama5_alt_dt_board_compat, .l2c_aux_mask = ~0UL, MACHINE_END @@ -62,7 +63,6 @@ MACHINE_END static void __init sama5d2_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sama5d2_pm_init(); } static const char *const sama5d2_compat[] __initconst = { @@ -74,6 +74,7 @@ DT_MACHINE_START(sama5d2, "Atmel SAMA5") /* Maintainer: Atmel */ .init_machine = sama5d2_init, .init_early = sama5_secure_cache_init, + .init_late = sama5d2_pm_init, .dt_compat = sama5d2_compat, .l2c_aux_mask = ~0UL, MACHINE_END diff --git a/arch/arm/mach-at91/sama7.c b/arch/arm/mach-at91/sama7.c index bd43733ede18..8bf57a020f1c 100644 --- a/arch/arm/mach-at91/sama7.c +++ b/arch/arm/mach-at91/sama7.c @@ -17,7 +17,6 @@ static void __init sama7_dt_device_init(void) { of_platform_default_populate(NULL, NULL, NULL); - sama7_pm_init(); } static const char *const sama7_dt_board_compat[] __initconst = { @@ -27,6 +26,7 @@ static const char *const sama7_dt_board_compat[] __initconst = { DT_MACHINE_START(sama7_dt, "Microchip SAMA7") /* Maintainer: Microchip */ + .init_late = sama7_pm_init, .init_machine = sama7_dt_device_init, .dt_compat = sama7_dt_board_compat, MACHINE_END From 0b0f7e6539a7507689445f8a0cace17305272bfe Mon Sep 17 00:00:00 2001 From: "Rob Herring (Arm)" Date: Mon, 5 Jan 2026 15:06:45 -0600 Subject: [PATCH 4/4] ARM: at91: remove unnecessary of_platform_default_populate calls The DT core will call of_platform_default_populate, so it is not necessary for machine specific code to call it unless there are custom match entries, auxdata or parent device. Neither of those apply here, so remove the call. Acked-by: Alexandre Belloni Tested-by: Alexandre Belloni Signed-off-by: Rob Herring (Arm) Link: https://lore.kernel.org/r/20260105-at91-probe-v3-3-594013ff2965@kernel.org Signed-off-by: Claudiu Beznea --- arch/arm/mach-at91/at91rm9200.c | 9 --------- arch/arm/mach-at91/at91sam9.c | 9 --------- arch/arm/mach-at91/sam9x60.c | 9 --------- arch/arm/mach-at91/sam9x7.c | 9 --------- arch/arm/mach-at91/sama5.c | 16 ---------------- arch/arm/mach-at91/sama7.c | 9 --------- 6 files changed, 61 deletions(-) diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 2ac564eb8bbb..d15997fff5d7 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c @@ -7,18 +7,10 @@ * 2012 Joachim Eastwood */ -#include -#include - #include #include "generic.h" -static void __init at91rm9200_dt_device_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const at91rm9200_dt_board_compat[] __initconst = { "atmel,at91rm9200", NULL @@ -26,6 +18,5 @@ static const char *const at91rm9200_dt_board_compat[] __initconst = { DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200") .init_late = at91rm9200_pm_init, - .init_machine = at91rm9200_dt_device_init, .dt_compat = at91rm9200_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c index cf07cba4ee5d..b9d2909d1b65 100644 --- a/arch/arm/mach-at91/at91sam9.c +++ b/arch/arm/mach-at91/at91sam9.c @@ -6,19 +6,11 @@ * 2011 Nicolas Ferre */ -#include -#include - #include #include #include "generic.h" -static void __init at91sam9_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const at91_dt_board_compat[] __initconst = { "atmel,at91sam9", NULL @@ -27,6 +19,5 @@ static const char *const at91_dt_board_compat[] __initconst = { DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM9") /* Maintainer: Atmel */ .init_late = at91sam9_pm_init, - .init_machine = at91sam9_init, .dt_compat = at91_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sam9x60.c b/arch/arm/mach-at91/sam9x60.c index a31beaaeffcd..744bab2cbb92 100644 --- a/arch/arm/mach-at91/sam9x60.c +++ b/arch/arm/mach-at91/sam9x60.c @@ -7,19 +7,11 @@ * Author: Claudiu Beznea */ -#include -#include - #include #include #include "generic.h" -static void __init sam9x60_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const sam9x60_dt_board_compat[] __initconst = { "microchip,sam9x60", NULL @@ -28,6 +20,5 @@ static const char *const sam9x60_dt_board_compat[] __initconst = { DT_MACHINE_START(sam9x60_dt, "Microchip SAM9X60") /* Maintainer: Microchip */ .init_late = sam9x60_pm_init, - .init_machine = sam9x60_init, .dt_compat = sam9x60_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sam9x7.c b/arch/arm/mach-at91/sam9x7.c index 0c73f7fefd4f..166c8625509d 100644 --- a/arch/arm/mach-at91/sam9x7.c +++ b/arch/arm/mach-at91/sam9x7.c @@ -7,18 +7,10 @@ * Author: Varshini Rajendran */ -#include -#include - #include #include "generic.h" -static void __init sam9x7_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char * const sam9x7_dt_board_compat[] __initconst = { "microchip,sam9x7", NULL @@ -27,6 +19,5 @@ static const char * const sam9x7_dt_board_compat[] __initconst = { DT_MACHINE_START(sam9x7_dt, "Microchip SAM9X7") /* Maintainer: Microchip */ .init_late = sam9x7_pm_init, - .init_machine = sam9x7_init, .dt_compat = sam9x7_dt_board_compat, MACHINE_END diff --git a/arch/arm/mach-at91/sama5.c b/arch/arm/mach-at91/sama5.c index 576654cba82d..e56022f00800 100644 --- a/arch/arm/mach-at91/sama5.c +++ b/arch/arm/mach-at91/sama5.c @@ -6,9 +6,6 @@ * 2013 Ludovic Desroches */ -#include -#include - #include #include #include @@ -30,11 +27,6 @@ static void __init sama5_secure_cache_init(void) outer_cache.write_sec = sama5_l2c310_write_sec; } -static void __init sama5_dt_device_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const sama5_dt_board_compat[] __initconst = { "atmel,sama5", NULL @@ -43,7 +35,6 @@ static const char *const sama5_dt_board_compat[] __initconst = { DT_MACHINE_START(sama5_dt, "Atmel SAMA5") /* Maintainer: Atmel */ .init_late = sama5_pm_init, - .init_machine = sama5_dt_device_init, .dt_compat = sama5_dt_board_compat, MACHINE_END @@ -54,17 +45,11 @@ static const char *const sama5_alt_dt_board_compat[] __initconst = { DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5") /* Maintainer: Atmel */ - .init_machine = sama5_dt_device_init, .init_late = sama5_pm_init, .dt_compat = sama5_alt_dt_board_compat, .l2c_aux_mask = ~0UL, MACHINE_END -static void __init sama5d2_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const sama5d2_compat[] __initconst = { "atmel,sama5d2", NULL @@ -72,7 +57,6 @@ static const char *const sama5d2_compat[] __initconst = { DT_MACHINE_START(sama5d2, "Atmel SAMA5") /* Maintainer: Atmel */ - .init_machine = sama5d2_init, .init_early = sama5_secure_cache_init, .init_late = sama5d2_pm_init, .dt_compat = sama5d2_compat, diff --git a/arch/arm/mach-at91/sama7.c b/arch/arm/mach-at91/sama7.c index 8bf57a020f1c..f56828d61199 100644 --- a/arch/arm/mach-at91/sama7.c +++ b/arch/arm/mach-at91/sama7.c @@ -6,19 +6,11 @@ * */ -#include -#include - #include #include #include "generic.h" -static void __init sama7_dt_device_init(void) -{ - of_platform_default_populate(NULL, NULL, NULL); -} - static const char *const sama7_dt_board_compat[] __initconst = { "microchip,sama7", NULL @@ -27,7 +19,6 @@ static const char *const sama7_dt_board_compat[] __initconst = { DT_MACHINE_START(sama7_dt, "Microchip SAMA7") /* Maintainer: Microchip */ .init_late = sama7_pm_init, - .init_machine = sama7_dt_device_init, .dt_compat = sama7_dt_board_compat, MACHINE_END