[PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak
xkernel
xkernel.wang at foxmail.com
Sun Dec 12 22:43:39 AEDT 2021
When some internal memory errors happend in of_iomap(), we should free
gpt to prevent memory leak.
Signed-off-by: xkernel <xkernel.wang at 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);
--
More information about the Linuxppc-dev
mailing list