powerpc: Fix missing of_node_put() calls
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 186 lines · Jyoti Gupta
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 <[email protected]>--- 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(-)arch/powerpc/kexec/file_load_64.c +1
-0@@ -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 ;arch/powerpc/kexec/file_load_64.c +0
-0}kexec_dprintk ("Memory node path: %s\n" , path);arch/powerpc/platforms/44x/iss4xx.c +2
-0@@ -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 arch/powerpc/platforms/44x/warp.c +1
-0@@ -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; }arch/powerpc/platforms/85xx/mpc85xx_8259.c +1
-0@@ -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 ; }arch/powerpc/platforms/86xx/pic.c +1
-0@@ -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 ; }arch/powerpc/platforms/pasemi/setup.c +1
-0@@ -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 ; }arch/powerpc/platforms/powermac/pci.c +1
-0@@ -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 ();arch/powerpc/platforms/powermac/smp.c +2
-0@@ -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 ; }arch/powerpc/platforms/powermac/smp.c +0
-0if (pmac_tb_freeze !=NULL ) {arch/powerpc/platforms/pseries/hotplug-cpu.c +0
-0@@ -637,16 +637,16 @@ static unsigned intpseries_cpuhp_cache_use_count(const struct
device_node*cacharch/powerpc/platforms/pseries/hotplug-cpu.c +2
-2for_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;arch/powerpc/sysdev/mpic.c +1
-1@@ -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; }arch/powerpc/sysdev/mpic.c +1
-1}@@ -1493,7 +1493,7 @@ struct mpic * __init mpic_alloc(structdevice_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) {