diff options
author | Zheng Yongjun <zhengyongjun3@huawei.com> | 2022-11-17 06:20:11 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-12-08 11:22:58 +0100 |
commit | bbf6d1bc077f956a609b5d781164d560600719be (patch) | |
tree | 26ec61de70adac9ccf69df1a38c006c3c5381570 | |
parent | 3afa86449ee8e5830169f7c15bdbb9dc6e5fe2ae (diff) | |
download | linux-stable-bbf6d1bc077f956a609b5d781164d560600719be.tar.gz linux-stable-bbf6d1bc077f956a609b5d781164d560600719be.tar.bz2 linux-stable-bbf6d1bc077f956a609b5d781164d560600719be.zip |
ARM: mxs: fix memory leak in mxs_machine_init()
[ Upstream commit f31e3c204d1844b8680a442a48868af5ac3d5481 ]
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>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | arch/arm/mach-mxs/mach-mxs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c index c109f47e9cbc..a687e83ad604 100644 --- a/arch/arm/mach-mxs/mach-mxs.c +++ b/arch/arm/mach-mxs/mach-mxs.c @@ -387,8 +387,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(); |