[PATCH] soc: realview: Fix memory leak in realview_soc_probe()
Yuan Can
yuancan at huawei.com
Thu Nov 17 00:44:09 PST 2022
If of_property_read_string() failed, soc_dev_attr should be freed before
return, otherwise the soc_dev_attr leaked.
Fixes: a2974c9c1f83 ("soc: add driver for the ARM RealView")
Signed-off-by: Yuan Can <yuancan at huawei.com>
---
drivers/soc/versatile/soc-realview.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index c6876d232d8f..ac7e976b3e06 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -99,8 +99,10 @@ static int realview_soc_probe(struct platform_device *pdev)
ret = of_property_read_string(np, "compatible",
&soc_dev_attr->soc_id);
- if (ret)
+ if (ret) {
+ kfree(soc_dev_attr);
return -EINVAL;
+ }
soc_dev_attr->machine = "RealView";
soc_dev_attr->family = "Versatile";
--
2.17.1
More information about the linux-arm-kernel
mailing list