linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nishka Dasgupta <nishkadg.linux@gmail.com>
To: horms@verge.net.au, geert+renesas@glider.be,
	magnus.damm@gmail.com, linux-renesas-soc@vger.kernel.org
Cc: Nishka Dasgupta <nishkadg.linux@gmail.com>
Subject: [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return
Date: Thu, 15 Aug 2019 11:43:54 +0530	[thread overview]
Message-ID: <20190815061355.4415-1-nishkadg.linux@gmail.com> (raw)

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


             reply	other threads:[~2019-08-15  6:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-15  6:13 Nishka Dasgupta [this message]
2019-08-16  7:26 ` [PATCH] soc: renesas: rcar-sysc: Add goto to of_node_put() before return Geert Uytterhoeven

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=20190815061355.4415-1-nishkadg.linux@gmail.com \
    --to=nishkadg.linux@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=horms@verge.net.au \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.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;
as well as URLs for NNTP newsgroup(s).