From: "xkernel.wang@foxmail.com" <xkernel.wang@foxmail.com>
To: mpe <mpe@ellerman.id.au>, agust <agust@denx.de>
Cc: benh <benh@kernel.crashing.org>, paulus <paulus@samba.org>,
linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak
Date: Mon, 13 Dec 2021 10:26:41 +0800 [thread overview]
Message-ID: <tencent_C982943047E43271285358863729A5FF630A@qq.com> (raw)
Message-ID: <202112131026410462899@foxmail.com> (raw)
Michael Ellerman <mpe@ellerman.id.au> wrote:
> > 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?
Yes, maybe you are right. I did that as I mentioned when gpt-regs is NULL, it
will return -ENOMEM, which is the same when gpt is NULL. So I suppose to
free it in time is better:
> gpt = devm_kzalloc(&ofdev->dev, sizeof *gpt, GFP_KERNEL);
> if (!gpt)
> return -ENOMEM;
cheers
next reply other threads:[~2021-12-13 2:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <202112131026410462899@foxmail.com>
2021-12-13 2:26 ` xkernel.wang [this message]
2021-12-12 11:43 [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak xkernel
2021-12-13 2:07 ` Michael Ellerman
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=tencent_C982943047E43271285358863729A5FF630A@qq.com \
--to=xkernel.wang@foxmail.com \
--cc=agust@denx.de \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox