LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jyoti Gupta <jyoti@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
	chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
	sourabhjain@linux.ibm.com
Subject: [PATCH] powerpc: Fix missing of_node_put() calls
Date: Wed, 30 Sep 2026 23:53:04 +0530	[thread overview]
Message-ID: <20260930182304.341123-1-jyoti@linux.ibm.com> (raw)

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.

Signed-off-by: Jyoti Gupta <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/powermac/smp.c        | 2 ++
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 ++--
 9 files changed, 12 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 45792ecd5dfd..b016e27b20ee 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -274,6 +274,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/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 88e92af8acf9..82c5f49576c5 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -591,11 +591,13 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
 				pmac_tb_freeze = smp_core99_cypress_tb_freeze;
 				name = "Cypress";
 			}
+			of_node_put(cc);
 			break;
 		case 0xd4:
 			pmac_tb_freeze = smp_core99_pulsar_tb_freeze;
 			pmac_tb_pulsar_addr = 0xd4;
 			name = "Pulsar";
+			of_node_put(cc);
 			break;
 		}
 		if (pmac_tb_freeze != NULL) {
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



             reply	other threads:[~2026-09-30 18:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 18:23 Jyoti Gupta [this message]
     [not found] <20260924061132.178744-1-jyoti@linux.ibm.com>
2026-09-24  6:17 ` [PATCH] powerpc: Fix missing of_node_put() calls jyoti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930182304.341123-1-jyoti@linux.ibm.com \
    --to=jyoti@linux.ibm.com \
    --cc=chleroy@kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox