[PATCH] thermal: imx_sc_thermal: drop child node when break loop
Pan Bian
bianpan2016 at 163.com
Thu Jan 21 21:28:18 EST 2021
Call of_node_put() to decrement the reference count of the child node
when jumping out of the loop body of for_each_available_child_of_node(),
which is a macro that increments and decrements the reference count of
child node. If the loop is broken, the reference of the child node should
be dropped manually.
Fixes: e20db70dba1c ("thermal: imx_sc: add i.MX system controller thermal support")
Signed-off-by: Pan Bian <bianpan2016 at 163.com>
---
drivers/thermal/imx_sc_thermal.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c
index b01d28eca7ee..404cab7221e3 100644
--- a/drivers/thermal/imx_sc_thermal.c
+++ b/drivers/thermal/imx_sc_thermal.c
@@ -93,6 +93,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
for_each_available_child_of_node(np, child) {
sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL);
if (!sensor) {
+ of_node_put(child);
of_node_put(sensor_np);
return -ENOMEM;
}
@@ -104,6 +105,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"failed to get valid sensor resource id: %d\n",
ret);
+ of_node_put(child);
break;
}
@@ -113,6 +115,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
&imx_sc_thermal_ops);
if (IS_ERR(sensor->tzd)) {
dev_err(&pdev->dev, "failed to register thermal zone\n");
+ of_node_put(child);
ret = PTR_ERR(sensor->tzd);
break;
}
--
2.17.1
More information about the linux-arm-kernel
mailing list