Skip to contentSkip to conversation

soc: renesas: rcar-sysc: Add goto to of_node_put() before return

PATCH Applied Nishka Dasgupta 2 participants 2 messages Aug 15, 2019 – Aug 16, 2019 Arm/RISC-V/Renesas architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: renesas: rcar-sysc: Add goto to of_node_put() before return

The local variable np in function rcar_sysc_pd_init takes the return value of of_find_matching_node_and_match, which gets a node but does not put it. If np is not put before the function returns, it may cause a memory leak. Hence, remove the return statement that does not immediately follow a putting of np. Replace it with a goto pointing to a pre-existing label that first puts np and then returns the required value.
Issue found with Coccinelle.

---
 drivers/soc/renesas/rcar-sysc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/renesas/rcar-sysc.c +1 -1
index 0c80fab4f8de..8a53f18d0429 100644
@@ -346,7 +346,7 @@ static int __init rcar_sysc_pd_init(void)
 	if (info->init) {
 		error = info->init();
 		if (error)
-			return error;
+			goto out_put;
 	}
 
 	has_cpg_mstp = of_find_compatible_node(NULL, NULL,
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1 Applied
#1 lore raw

Thanks, applied and queued for v5.4.On Thu, Aug 15, 2019 at 8:14 AM

Quoted 10 lines · Nishka Dasgupta

The local variable np in function rcar_sysc_pd_init takes the return value of of_find_matching_node_and_match, which gets a node but does not put it. If np is not put before the function returns, it may cause a memory leak. Hence, remove the return statement that does not immediately follow a putting of np. Replace it with a goto pointing to a pre-existing label that first puts np and then returns the required value.
Issue found with Coccinelle.

Fixes afa6f53df6052968 ("soc: renesas: rcar-sysc: Add support for

fixing up power area tables")

i.e. will queue in renesas-devel for v5.4.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds