2020-05-06 06:02:23

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] firmware: imx: scu: Fix possible memory leak in imx_scu_probe()

'chan_name' is malloced in imx_scu_probe() and should be freed
before leaving from the error handling cases, otherwise it will
cause memory leak.

Fixes: edbee095fafb ("firmware: imx: add SCU firmware driver support")
Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/firmware/imx/imx-scu.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
index b3da2e193ad2..176ddd151375 100644
--- a/drivers/firmware/imx/imx-scu.c
+++ b/drivers/firmware/imx/imx-scu.c
@@ -314,6 +314,7 @@ static int imx_scu_probe(struct platform_device *pdev)
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to request mbox chan %s ret %d\n",
chan_name, ret);
+ kfree(chan_name);
return ret;
}




2020-05-06 11:13:56

by Aisheng Dong

[permalink] [raw]
Subject: RE: [PATCH -next] firmware: imx: scu: Fix possible memory leak in imx_scu_probe()

> From: Wei Yongjun <[email protected]>
> Sent: Wednesday, May 6, 2020 1:14 PM
>
> 'chan_name' is malloced in imx_scu_probe() and should be freed before leaving
> from the error handling cases, otherwise it will cause memory leak.
>
> Fixes: edbee095fafb ("firmware: imx: add SCU firmware driver support")
> Signed-off-by: Wei Yongjun <[email protected]>

Thanks for the fix.
Reviewed-by: Dong Aisheng <[email protected]>

Regards
Aisheng

2020-05-20 01:17:57

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH -next] firmware: imx: scu: Fix possible memory leak in imx_scu_probe()

On Wed, May 06, 2020 at 05:14:10AM +0000, Wei Yongjun wrote:
> 'chan_name' is malloced in imx_scu_probe() and should be freed
> before leaving from the error handling cases, otherwise it will
> cause memory leak.
>
> Fixes: edbee095fafb ("firmware: imx: add SCU firmware driver support")
> Signed-off-by: Wei Yongjun <[email protected]>

Applied, thanks.