From: Wolfram Sang <wsa@the-dreams.de>
To: Nishka Dasgupta <nishkadg.linux@gmail.com>
Cc: eajames@linux.ibm.com, linux-i2c@vger.kernel.org,
openbmc@lists.ozlabs.org
Subject: Re: [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break
Date: Tue, 3 Sep 2019 20:15:01 +0200 [thread overview]
Message-ID: <20190903181501.GJ2171@ninjato> (raw)
In-Reply-To: <20190706131911.3068-1-nishkadg.linux@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]
On Sat, Jul 06, 2019 at 06:49:11PM +0530, Nishka Dasgupta wrote:
> Each iteration of for_each_available_childe_of_node puts the previous
> node, but in the case of a break from the middle of the loop, there
> is no put, thus causing a memory leak. Add an of_node_put before the
> break.
> Issue found with Coccinelle.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
Eddie, are you okay with this change?
> drivers/i2c/busses/i2c-fsi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
> index 1e2be2219a60..5e01875082c3 100644
> --- a/drivers/i2c/busses/i2c-fsi.c
> +++ b/drivers/i2c/busses/i2c-fsi.c
> @@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)
> continue;
>
> port = kzalloc(sizeof(*port), GFP_KERNEL);
> - if (!port)
> + if (!port) {
> + of_node_put(np);
> break;
> + }
>
> port->master = i2c;
> port->port = port_no;
> --
> 2.19.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-09-03 23:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-06 13:19 [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break Nishka Dasgupta
2019-09-03 18:15 ` Wolfram Sang [this message]
2019-09-03 18:18 ` Eddie James
2019-09-03 18:33 ` Wolfram Sang
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=20190903181501.GJ2171@ninjato \
--to=wsa@the-dreams.de \
--cc=eajames@linux.ibm.com \
--cc=linux-i2c@vger.kernel.org \
--cc=nishkadg.linux@gmail.com \
--cc=openbmc@lists.ozlabs.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.