Skip to contentSkip to conversation

soc: realview: Fix memory leak in realview_soc_probe()

PATCH In review Yuan Can 2 participants 2 messages Nov 17, 2022 – Sep 13, 2023 Arm integrator, versatile and realview support

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 soc: realview: Fix memory leak in realview_soc_probe()

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")
---
 drivers/soc/versatile/soc-realview.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/versatile/soc-realview.c +3 -1
index c6876d232d8f..ac7e976b3e06 100644
@@ -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";
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 5 lines · Yuan Can

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")

Hi Yuan,

thanks for your patch! I have applied it to my tree and I will send it upstream ASAP.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel