mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: xkernel <xkernel.wang@foxmail.com>
To: agust@denx.de
Cc: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	xkernel <xkernel.wang@foxmail.com>
Subject: [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak
Date: Sun, 12 Dec 2021 19:43:39 +0800	[thread overview]
Message-ID: <tencent_765F05E486793F9790A388C2289C5429F705@qq.com> (raw)

When some internal memory errors happend in of_iomap(), we should free
gpt to prevent memory leak.

Signed-off-by: xkernel <xkernel.wang@foxmail.com>
---
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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);
 
-- 

             reply	other threads:[~2021-12-12 12:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 11:43 xkernel [this message]
2021-12-13  2:07 ` Michael Ellerman
     [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=tencent_765F05E486793F9790A388C2289C5429F705@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

all inboxes | Powered by JetHome®