Blob Blame History Raw
From da51ceda8ab054bf3b4c5cf86a8deec7d7849a5c Mon Sep 17 00:00:00 2001
From: Nishka Dasgupta <nishkadg.linux@gmail.com>
Date: Thu, 15 Aug 2019 11:43:54 +0530
Subject: [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return
Git-commit: da51ceda8ab054bf3b4c5cf86a8deec7d7849a5c
Patch-mainline: v5.4-rc1
References: bsc#1051510

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")
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 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 02b29ea62dc4..54baa2fe8527 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.16.4