linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return
@ 2019-08-15  6:13 Nishka Dasgupta
  2019-08-16  7:26 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-08-15  6:13 UTC (permalink / raw)
  To: horms, geert+renesas, magnus.damm, linux-renesas-soc; +Cc: 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.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/soc/renesas/rcar-sysc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
index 0c80fab4f8de..8a53f18d0429 100644
--- a/drivers/soc/renesas/rcar-sysc.c
+++ b/drivers/soc/renesas/rcar-sysc.c
@@ -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,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return
  2019-08-15  6:13 [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return Nishka Dasgupta
@ 2019-08-16  7:26 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2019-08-16  7:26 UTC (permalink / raw)
  To: Nishka Dasgupta
  Cc: Simon Horman, Geert Uytterhoeven, Magnus Damm, Linux-Renesas

Thanks, applied and queued for v5.4.On Thu, Aug 15, 2019 at 8:14 AM
Nishka Dasgupta <nishkadg.linux@gmail.com> wrote:
> 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.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>

Fixes: afa6f53df6052968 ("soc: renesas: rcar-sysc: Add support for
fixing up power area tables")
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-devel for v5.4.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-16  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15  6:13 [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return Nishka Dasgupta
2019-08-16  7:26 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).