From: Michael Ellerman <mpe@ellerman.id.au>
To: xkernel <xkernel.wang@foxmail.com>, agust@denx.de
Cc: benh@kernel.crashing.org, paulus@samba.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
xkernel <xkernel.wang@foxmail.com>
Subject: Re: [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak
Date: Mon, 13 Dec 2021 13:07:18 +1100 [thread overview]
Message-ID: <87lf0pmf55.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <tencent_765F05E486793F9790A388C2289C5429F705@qq.com>
xkernel <xkernel.wang@foxmail.com> writes:
> When some internal memory errors happend in of_iomap(), we should free
> gpt to prevent memory leak.
But it's allocated with devm_kzalloc(), so the devres core is meant to
free it for us isn't it?
cheers
> diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> index f862b48..c506cfd 100644
> --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> @@ -722,8 +722,10 @@ static int mpc52xx_gpt_probe(struct platform_device *ofdev)
> gpt->dev = &ofdev->dev;
> gpt->ipb_freq = mpc5xxx_get_bus_frequency(ofdev->dev.of_node);
> gpt->regs = of_iomap(ofdev->dev.of_node, 0);
> - if (!gpt->regs)
> + if (!gpt->regs) {
> + devm_kfree(&ofdev->dev, gpt);
> return -ENOMEM;
> + }
>
> dev_set_drvdata(&ofdev->dev, gpt);
>
> --
next prev parent reply other threads:[~2021-12-13 2:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 11:43 [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak xkernel
2021-12-13 2:07 ` Michael Ellerman [this message]
[not found] <202112131026410462899@foxmail.com>
2021-12-13 2:26 ` xkernel.wang
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=87lf0pmf55.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=agust@denx.de \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=xkernel.wang@foxmail.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