* [PATCH] ARM: mxs: fix memory leak in mxs_machine_init()
@ 2022-11-17 6:20 Zheng Yongjun
2022-11-17 9:13 ` Marco Felsch
0 siblings, 1 reply; 3+ messages in thread
From: Zheng Yongjun @ 2022-11-17 6:20 UTC (permalink / raw)
To: shawnguo, s.hauer, linux-arm-kernel, linux-kernel
Cc: kernel, festevam, linux-imx
If of_property_read_string() failed, 'soc_dev_attr' should be
freed before return. Otherwise there is a memory leak.
Fixes: 2046338dcbc6 ("ARM: mxs: Use soc bus infrastructure")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
arch/arm/mach-mxs/mach-mxs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 25c9d184fa4c..1c57ac401649 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -393,8 +393,10 @@ static void __init mxs_machine_init(void)
root = of_find_node_by_path("/");
ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
- if (ret)
+ if (ret) {
+ kfree(soc_dev_attr);
return;
+ }
soc_dev_attr->family = "Freescale MXS Family";
soc_dev_attr->soc_id = mxs_get_soc_id();
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: mxs: fix memory leak in mxs_machine_init()
2022-11-17 6:20 [PATCH] ARM: mxs: fix memory leak in mxs_machine_init() Zheng Yongjun
@ 2022-11-17 9:13 ` Marco Felsch
2022-11-19 1:41 ` Shawn Guo
0 siblings, 1 reply; 3+ messages in thread
From: Marco Felsch @ 2022-11-17 9:13 UTC (permalink / raw)
To: Zheng Yongjun
Cc: shawnguo, s.hauer, linux-arm-kernel, linux-kernel, festevam,
linux-imx, kernel
On 22-11-17, Zheng Yongjun wrote:
> If of_property_read_string() failed, 'soc_dev_attr' should be
> freed before return. Otherwise there is a memory leak.
>
> Fixes: 2046338dcbc6 ("ARM: mxs: Use soc bus infrastructure")
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> arch/arm/mach-mxs/mach-mxs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
> index 25c9d184fa4c..1c57ac401649 100644
> --- a/arch/arm/mach-mxs/mach-mxs.c
> +++ b/arch/arm/mach-mxs/mach-mxs.c
> @@ -393,8 +393,10 @@ static void __init mxs_machine_init(void)
>
> root = of_find_node_by_path("/");
> ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
> - if (ret)
> + if (ret) {
> + kfree(soc_dev_attr);
> return;
> + }
>
> soc_dev_attr->family = "Freescale MXS Family";
> soc_dev_attr->soc_id = mxs_get_soc_id();
> --
> 2.17.1
>
>
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: mxs: fix memory leak in mxs_machine_init()
2022-11-17 9:13 ` Marco Felsch
@ 2022-11-19 1:41 ` Shawn Guo
0 siblings, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2022-11-19 1:41 UTC (permalink / raw)
To: Marco Felsch
Cc: Zheng Yongjun, s.hauer, linux-arm-kernel, linux-kernel, festevam,
linux-imx, kernel
On Thu, Nov 17, 2022 at 10:13:15AM +0100, Marco Felsch wrote:
> On 22-11-17, Zheng Yongjun wrote:
> > If of_property_read_string() failed, 'soc_dev_attr' should be
> > freed before return. Otherwise there is a memory leak.
> >
> > Fixes: 2046338dcbc6 ("ARM: mxs: Use soc bus infrastructure")
> > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
>
> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Applied, thanks!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-19 1:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-17 6:20 [PATCH] ARM: mxs: fix memory leak in mxs_machine_init() Zheng Yongjun
2022-11-17 9:13 ` Marco Felsch
2022-11-19 1:41 ` Shawn Guo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).