From: Marc Zyngier <marc.zyngier@arm.com>
To: Nishka Dasgupta <nishkadg.linux@gmail.com>
Cc: tglx@linutronix.de, jason@lakedaemon.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irqchip: irq-mbigen: Add of_node_put() before return
Date: Fri, 26 Jul 2019 14:22:29 +0100 [thread overview]
Message-ID: <867e85nd62.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20190723103910.8006-1-nishkadg.linux@gmail.com>
On Tue, 23 Jul 2019 11:39:10 +0100,
Nishka Dasgupta <nishkadg.linux@gmail.com> wrote:
>
> Each iteration of for_each_child_of_node puts the previous node, but
> in the case of a return from the middle of the loop, there is no put,
> thus causing a memory leak. Add an of_node_put before the return in
> three places.
> Issue found with Coccinelle.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
> drivers/irqchip/irq-mbigen.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
> index 3dd28382d5f5..3f09f658e8e2 100644
> --- a/drivers/irqchip/irq-mbigen.c
> +++ b/drivers/irqchip/irq-mbigen.c
> @@ -241,12 +241,15 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
>
> parent = platform_bus_type.dev_root;
> child = of_platform_device_create(np, NULL, parent);
> - if (!child)
> + if (!child) {
> + of_node_put(np);
> return -ENOMEM;
> + }
>
> if (of_property_read_u32(child->dev.of_node, "num-pins",
> &num_pins) < 0) {
> dev_err(&pdev->dev, "No num-pins property\n");
> + of_node_put(np);
> return -EINVAL;
> }
>
> @@ -254,8 +257,10 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
> mbigen_write_msg,
> &mbigen_domain_ops,
> mgn_chip);
> - if (!domain)
> + if (!domain) {
> + of_node_put(np);
> return -ENOMEM;
> + }
> }
>
> return 0;
> --
> 2.19.1
>
Applied, thanks.
M.
--
Jazz is not dead, it just smells funny.
prev parent reply other threads:[~2019-07-26 13:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 10:39 [PATCH] irqchip: irq-mbigen: Add of_node_put() before return Nishka Dasgupta
2019-07-26 13:22 ` Marc Zyngier [this message]
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=867e85nd62.wl-marc.zyngier@arm.com \
--to=marc.zyngier@arm.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nishkadg.linux@gmail.com \
--cc=tglx@linutronix.de \
/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).