* [PATCH v2] powerpc: Fix missing of_node_put() calls
@ 2026-11-19 7:58 Jyoti Gupta
2026-11-20 3:41 ` Ritesh Harjani
0 siblings, 1 reply; 3+ messages in thread
From: Jyoti Gupta @ 2026-11-19 7:58 UTC (permalink / raw)
To: linuxppc-dev
Cc: maddy, npiggin, chleroy, ritesh.list, sshegde, oss, Sourabh Jain
Several PowerPC code paths acquire device tree node references but fail
to drop them on error paths, early exits.
Add the missing of_node_put() calls across PowerPC platform to ensure
proper device node reference counting.
These changes prevent device node reference leaks and improve overall
resource management in PowerPC code.
Suggested-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Jyoti Gupta <jyoti@linux.ibm.com>
---
Changelog:
v1 -> v2:
- Rebased onto latest upstream.
- Dropped the powermac/smp.c hunk: there is no leak there. The loop
iterator drops cc on continue/advance and the existing code puts it
before the break, so the added of_node_put() calls were a double put.
- Added Suggested-by tag.
- Link to v1 - https://lore.kernel.org/all/20260930182304.341123-1-jyoti@linux.ibm.com/
---
arch/powerpc/kexec/file_load_64.c | 1 +
arch/powerpc/platforms/44x/iss4xx.c | 2 ++
arch/powerpc/platforms/44x/warp.c | 1 +
arch/powerpc/platforms/85xx/mpc85xx_8259.c | 1 +
arch/powerpc/platforms/86xx/pic.c | 1 +
arch/powerpc/platforms/pasemi/setup.c | 1 +
arch/powerpc/platforms/powermac/pci.c | 1 +
arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
8 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
index bd80c5fb1b1f..8d4d6a51c046 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -204,6 +204,7 @@ static int add_usable_mem_property(void *fdt, struct device_node *dn,
if (snprintf(path, NODE_PATH_LEN, "%pOF", dn) > (NODE_PATH_LEN - 1)) {
pr_err("Buffer (%d) too small for memory node: %pOF\n",
NODE_PATH_LEN, dn);
+ of_node_put(dn);
return -EOVERFLOW;
}
kexec_dprintk("Memory node path: %s\n", path);
diff --git a/arch/powerpc/platforms/44x/iss4xx.c b/arch/powerpc/platforms/44x/iss4xx.c
index ef883d97fe15..ef92b4656d17 100644
--- a/arch/powerpc/platforms/44x/iss4xx.c
+++ b/arch/powerpc/platforms/44x/iss4xx.c
@@ -74,6 +74,8 @@ static void __init iss4xx_init_irq(void)
#endif
} else
panic("Unrecognized top level interrupt controller");
+
+ of_node_put(np);
}
#ifdef CONFIG_SMP
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 6f674f86dc85..49afd60b1c30 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -183,6 +183,7 @@ static int pika_setup_leds(void)
printk(KERN_ERR __FILE__ ": Failed to get %s led gpio: %d\n",
led->name, error);
of_node_put(child);
+ of_node_put(np);
goto err_cleanup_pins;
}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_8259.c b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
index cb00d596ad80..9b7283038892 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_8259.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
@@ -52,6 +52,7 @@ void __init mpc85xx_8259_init(void)
cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (!cascade_irq) {
pr_err("i8259: Failed to map cascade interrupt\n");
+ of_node_put(cascade_node);
return;
}
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index 9ca36de23532..4cbcc16b1009 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -58,6 +58,7 @@ void __init mpc86xx_init_irq(void)
cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (!cascade_irq) {
printk(KERN_ERR "Failed to map cascade interrupt\n");
+ of_node_put(cascade_node);
return;
}
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 7a961f2a228f..a82855752e58 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -272,6 +272,7 @@ static __init void pas_init_IRQ(void)
opprop = of_get_property(root, "platform-open-pic", &opplen);
if (!opprop) {
pr_err("No platform-open-pic property.\n");
+ of_node_put(mpic_node);
of_node_put(root);
return;
}
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index d71359b5331c..8bc56a70b4c8 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -938,6 +938,7 @@ void __init pmac_pci_init(void)
/* pmac_check_ht_link(); */
#else /* CONFIG_PPC64 */
+ of_node_put(ht);
init_p2pbridge();
init_second_ohare();
fixup_nec_usb2();
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index bc6926dbf148..c4f7348aa035 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -637,16 +637,16 @@ static unsigned int pseries_cpuhp_cache_use_count(const struct device_node *cach
for_each_of_cpu_node(dn) {
tn = of_find_next_cache_node(dn);
- of_node_put(tn);
if (tn == cachedn)
use_count++;
+ of_node_put(tn);
}
for_each_node_by_type(dn, "cache") {
tn = of_find_next_cache_node(dn);
- of_node_put(tn);
if (tn == cachedn)
use_count++;
+ of_node_put(tn);
}
return use_count;
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] powerpc: Fix missing of_node_put() calls
2026-11-19 7:58 [PATCH v2] powerpc: Fix missing of_node_put() calls Jyoti Gupta
@ 2026-11-20 3:41 ` Ritesh Harjani
2026-11-20 6:37 ` Jyoti Gupta
0 siblings, 1 reply; 3+ messages in thread
From: Ritesh Harjani @ 2026-11-20 3:41 UTC (permalink / raw)
To: Jyoti Gupta, linuxppc-dev
Cc: maddy, npiggin, chleroy, sshegde, oss, Sourabh Jain
Jyoti Gupta <jyoti@linux.ibm.com> writes:
> Several PowerPC code paths acquire device tree node references but fail
> to drop them on error paths, early exits.
>
> Add the missing of_node_put() calls across PowerPC platform to ensure
> proper device node reference counting.
>
> These changes prevent device node reference leaks and improve overall
> resource management in PowerPC code.
>
> Suggested-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> Signed-off-by: Jyoti Gupta <jyoti@linux.ibm.com>
> ---
> Changelog:
> v1 -> v2:
> - Rebased onto latest upstream.
> - Dropped the powermac/smp.c hunk: there is no leak there. The loop
> iterator drops cc on continue/advance and the existing code puts it
> before the break, so the added of_node_put() calls were a double put.
> - Added Suggested-by tag.
> - Link to v1 - https://lore.kernel.org/all/20260930182304.341123-1-jyoti@linux.ibm.com/
> ---
> arch/powerpc/kexec/file_load_64.c | 1 +
> arch/powerpc/platforms/44x/iss4xx.c | 2 ++
> arch/powerpc/platforms/44x/warp.c | 1 +
> arch/powerpc/platforms/85xx/mpc85xx_8259.c | 1 +
> arch/powerpc/platforms/86xx/pic.c | 1 +
> arch/powerpc/platforms/pasemi/setup.c | 1 +
> arch/powerpc/platforms/powermac/pci.c | 1 +
> arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
> 8 files changed, 10 insertions(+), 2 deletions(-)
Mostly minor nits. Otherwise largely looks ok to me.
>
> diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c
> index bd80c5fb1b1f..8d4d6a51c046 100644
> --- a/arch/powerpc/kexec/file_load_64.c
> +++ b/arch/powerpc/kexec/file_load_64.c
> @@ -204,6 +204,7 @@ static int add_usable_mem_property(void *fdt, struct device_node *dn,
> if (snprintf(path, NODE_PATH_LEN, "%pOF", dn) > (NODE_PATH_LEN - 1)) {
> pr_err("Buffer (%d) too small for memory node: %pOF\n",
> NODE_PATH_LEN, dn);
> + of_node_put(dn);
> return -EOVERFLOW;
Instead can we use goto out and use the common cleanup defined in this function?
> }
> kexec_dprintk("Memory node path: %s\n", path);
> diff --git a/arch/powerpc/platforms/44x/iss4xx.c b/arch/powerpc/platforms/44x/iss4xx.c
> index ef883d97fe15..ef92b4656d17 100644
> --- a/arch/powerpc/platforms/44x/iss4xx.c
> +++ b/arch/powerpc/platforms/44x/iss4xx.c
> @@ -74,6 +74,8 @@ static void __init iss4xx_init_irq(void)
> #endif
> } else
> panic("Unrecognized top level interrupt controller");
> +
> + of_node_put(np);
> }
>
> #ifdef CONFIG_SMP
> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
> index 6f674f86dc85..49afd60b1c30 100644
> --- a/arch/powerpc/platforms/44x/warp.c
> +++ b/arch/powerpc/platforms/44x/warp.c
> @@ -183,6 +183,7 @@ static int pika_setup_leds(void)
> printk(KERN_ERR __FILE__ ": Failed to get %s led gpio: %d\n",
> led->name, error);
> of_node_put(child);
> + of_node_put(np);
> goto err_cleanup_pins;
> }
>
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_8259.c b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
> index cb00d596ad80..9b7283038892 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_8259.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
> @@ -52,6 +52,7 @@ void __init mpc85xx_8259_init(void)
> cascade_irq = irq_of_parse_and_map(cascade_node, 0);
> if (!cascade_irq) {
> pr_err("i8259: Failed to map cascade interrupt\n");
> + of_node_put(cascade_node);
> return;
> }
>
> diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
> index 9ca36de23532..4cbcc16b1009 100644
> --- a/arch/powerpc/platforms/86xx/pic.c
> +++ b/arch/powerpc/platforms/86xx/pic.c
> @@ -58,6 +58,7 @@ void __init mpc86xx_init_irq(void)
> cascade_irq = irq_of_parse_and_map(cascade_node, 0);
> if (!cascade_irq) {
> printk(KERN_ERR "Failed to map cascade interrupt\n");
> + of_node_put(cascade_node);
> return;
> }
>
> diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
> index 7a961f2a228f..a82855752e58 100644
> --- a/arch/powerpc/platforms/pasemi/setup.c
> +++ b/arch/powerpc/platforms/pasemi/setup.c
> @@ -272,6 +272,7 @@ static __init void pas_init_IRQ(void)
> opprop = of_get_property(root, "platform-open-pic", &opplen);
> if (!opprop) {
> pr_err("No platform-open-pic property.\n");
> + of_node_put(mpic_node);
> of_node_put(root);
> return;
> }
> diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
> index d71359b5331c..8bc56a70b4c8 100644
> --- a/arch/powerpc/platforms/powermac/pci.c
> +++ b/arch/powerpc/platforms/powermac/pci.c
> @@ -938,6 +938,7 @@ void __init pmac_pci_init(void)
> /* pmac_check_ht_link(); */
>
> #else /* CONFIG_PPC64 */
> + of_node_put(ht);
After this reference to ht, I think we can drop __maybe_unused during ht
declaration. I guess it must be added since on PPC32 it won't get
used and so compiler could complain for an unused variable.
-ritesh
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] powerpc: Fix missing of_node_put() calls
2026-11-20 3:41 ` Ritesh Harjani
@ 2026-11-20 6:37 ` Jyoti Gupta
0 siblings, 0 replies; 3+ messages in thread
From: Jyoti Gupta @ 2026-11-20 6:37 UTC (permalink / raw)
To: Ritesh Harjani
Cc: linuxppc-dev, maddy, npiggin, chleroy, sshegde, oss, Sourabh Jain
On 2026-11-20 09:11, Ritesh Harjani wrote:
> Jyoti Gupta <jyoti@linux.ibm.com> writes:
>
>> Several PowerPC code paths acquire device tree node references but
>> fail
>> to drop them on error paths, early exits.
>>
>> Add the missing of_node_put() calls across PowerPC platform to ensure
>> proper device node reference counting.
>>
>> These changes prevent device node reference leaks and improve overall
>> resource management in PowerPC code.
>>
>> Suggested-by: Sourabh Jain <sourabhjain@linux.ibm.com>
>> Signed-off-by: Jyoti Gupta <jyoti@linux.ibm.com>
>> ---
>> Changelog:
>> v1 -> v2:
>> - Rebased onto latest upstream.
>> - Dropped the powermac/smp.c hunk: there is no leak there. The loop
>> iterator drops cc on continue/advance and the existing code puts it
>> before the break, so the added of_node_put() calls were a double
>> put.
>> - Added Suggested-by tag.
>> - Link to v1 -
>> https://lore.kernel.org/all/20260930182304.341123-1-jyoti@linux.ibm.com/
>> ---
>> arch/powerpc/kexec/file_load_64.c | 1 +
>> arch/powerpc/platforms/44x/iss4xx.c | 2 ++
>> arch/powerpc/platforms/44x/warp.c | 1 +
>> arch/powerpc/platforms/85xx/mpc85xx_8259.c | 1 +
>> arch/powerpc/platforms/86xx/pic.c | 1 +
>> arch/powerpc/platforms/pasemi/setup.c | 1 +
>> arch/powerpc/platforms/powermac/pci.c | 1 +
>> arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
>> 8 files changed, 10 insertions(+), 2 deletions(-)
>
> Mostly minor nits. Otherwise largely looks ok to me.
>
Thankyou for the review.
>>
>> diff --git a/arch/powerpc/kexec/file_load_64.c
>> b/arch/powerpc/kexec/file_load_64.c
>> index bd80c5fb1b1f..8d4d6a51c046 100644
>> --- a/arch/powerpc/kexec/file_load_64.c
>> +++ b/arch/powerpc/kexec/file_load_64.c
>> @@ -204,6 +204,7 @@ static int add_usable_mem_property(void *fdt,
>> struct device_node *dn,
>> if (snprintf(path, NODE_PATH_LEN, "%pOF", dn) > (NODE_PATH_LEN - 1))
>> {
>> pr_err("Buffer (%d) too small for memory node: %pOF\n",
>> NODE_PATH_LEN, dn);
>> + of_node_put(dn);
>> return -EOVERFLOW;
>
> Instead can we use goto out and use the common cleanup defined in this
> function?
>
Agreed.Will fix in v3.
>> }
>> kexec_dprintk("Memory node path: %s\n", path);
>> diff --git a/arch/powerpc/platforms/44x/iss4xx.c
>> b/arch/powerpc/platforms/44x/iss4xx.c
>> index ef883d97fe15..ef92b4656d17 100644
>> --- a/arch/powerpc/platforms/44x/iss4xx.c
>> +++ b/arch/powerpc/platforms/44x/iss4xx.c
>> @@ -74,6 +74,8 @@ static void __init iss4xx_init_irq(void)
>> #endif
>> } else
>> panic("Unrecognized top level interrupt controller");
>> +
>> + of_node_put(np);
>> }
>>
>> #ifdef CONFIG_SMP
>> diff --git a/arch/powerpc/platforms/44x/warp.c
>> b/arch/powerpc/platforms/44x/warp.c
>> index 6f674f86dc85..49afd60b1c30 100644
>> --- a/arch/powerpc/platforms/44x/warp.c
>> +++ b/arch/powerpc/platforms/44x/warp.c
>> @@ -183,6 +183,7 @@ static int pika_setup_leds(void)
>> printk(KERN_ERR __FILE__ ": Failed to get %s led gpio: %d\n",
>> led->name, error);
>> of_node_put(child);
>> + of_node_put(np);
>> goto err_cleanup_pins;
>> }
>>
>> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_8259.c
>> b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
>> index cb00d596ad80..9b7283038892 100644
>> --- a/arch/powerpc/platforms/85xx/mpc85xx_8259.c
>> +++ b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
>> @@ -52,6 +52,7 @@ void __init mpc85xx_8259_init(void)
>> cascade_irq = irq_of_parse_and_map(cascade_node, 0);
>> if (!cascade_irq) {
>> pr_err("i8259: Failed to map cascade interrupt\n");
>> + of_node_put(cascade_node);
>> return;
>> }
>>
>> diff --git a/arch/powerpc/platforms/86xx/pic.c
>> b/arch/powerpc/platforms/86xx/pic.c
>> index 9ca36de23532..4cbcc16b1009 100644
>> --- a/arch/powerpc/platforms/86xx/pic.c
>> +++ b/arch/powerpc/platforms/86xx/pic.c
>> @@ -58,6 +58,7 @@ void __init mpc86xx_init_irq(void)
>> cascade_irq = irq_of_parse_and_map(cascade_node, 0);
>> if (!cascade_irq) {
>> printk(KERN_ERR "Failed to map cascade interrupt\n");
>> + of_node_put(cascade_node);
>> return;
>> }
>>
>> diff --git a/arch/powerpc/platforms/pasemi/setup.c
>> b/arch/powerpc/platforms/pasemi/setup.c
>> index 7a961f2a228f..a82855752e58 100644
>> --- a/arch/powerpc/platforms/pasemi/setup.c
>> +++ b/arch/powerpc/platforms/pasemi/setup.c
>> @@ -272,6 +272,7 @@ static __init void pas_init_IRQ(void)
>> opprop = of_get_property(root, "platform-open-pic", &opplen);
>> if (!opprop) {
>> pr_err("No platform-open-pic property.\n");
>> + of_node_put(mpic_node);
>> of_node_put(root);
>> return;
>> }
>> diff --git a/arch/powerpc/platforms/powermac/pci.c
>> b/arch/powerpc/platforms/powermac/pci.c
>> index d71359b5331c..8bc56a70b4c8 100644
>> --- a/arch/powerpc/platforms/powermac/pci.c
>> +++ b/arch/powerpc/platforms/powermac/pci.c
>> @@ -938,6 +938,7 @@ void __init pmac_pci_init(void)
>> /* pmac_check_ht_link(); */
>>
>> #else /* CONFIG_PPC64 */
>> + of_node_put(ht);
>
> After this reference to ht, I think we can drop __maybe_unused during
> ht
> declaration. I guess it must be added since on PPC32 it won't get
> used and so compiler could complain for an unused variable.
>
Agreed. With of_node_put(ht) now used on both PPC32 and PPC64, the
variable is no longer set-but-unused on PPC32, so the annotation is
redundant. I'll drop __maybe_unused in v3.
Thanks,
Jyoti Gupta
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 6:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 7:58 [PATCH v2] powerpc: Fix missing of_node_put() calls Jyoti Gupta
2026-11-20 3:41 ` Ritesh Harjani
2026-11-20 6:37 ` Jyoti Gupta
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.