LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: jyoti <jyoti@linux.ibm.com>
To: maddy@linux.ibm.com
Cc: mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org,
	ritesh.list@gmail.com, sshegde@linux.ibm.com,
	sourabhjain@linux.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc: Fix missing of_node_put() calls
Date: Thu, 24 Sep 2026 11:47:18 +0530	[thread overview]
Message-ID: <5cef10ab1610113fe162cec1dffd97f3@linux.ibm.com> (raw)
In-Reply-To: <20260924061132.178744-1-jyoti@linux.ibm.com>

On 2026-09-24 11:41, Jyoti Gupta wrote:
> 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 ++--
>  arch/powerpc/sysdev/mpic.c                   | 4 ++--
>  10 files changed, 14 insertions(+), 4 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;
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index 257886ec3f70..6e8fa94985f3 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -1389,7 +1389,7 @@ struct mpic * __init mpic_alloc(struct 
> device_node *node,
>  		if (fsl_version >= 0x401) {
>  			ret = mpic_setup_error_int(mpic, intvec_top - 13);
>  			if (ret)
> -				return NULL;
> +				goto err_of_node_put;
>  		}
> 
>  	}
> @@ -1493,7 +1493,7 @@ struct mpic * __init mpic_alloc(struct 
> device_node *node,
>  	 * is very unlikely to fail but it ought to be fixed anyways.
>  	 */
>  	if (mpic->irqhost == NULL)
> -		return NULL;
> +		goto err_of_node_put;
> 
>  	/* Display version */
>  	switch (greg_feature & MPIC_GREG_FEATURE_VERSION_MASK) {


       reply	other threads:[~2026-09-24 12:53 UTC|newest]

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

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=5cef10ab1610113fe162cec1dffd97f3@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