diff mbox series

thermal: imx_sc_thermal: drop child node when break loop

Message ID 20210122022818.39969-1-bianpan2016@163.com (mailing list archive)
State New, archived
Headers show
Series thermal: imx_sc_thermal: drop child node when break loop | expand

Commit Message

Pan Bian Jan. 22, 2021, 2:28 a.m. UTC
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@163.com>
 drivers/thermal/imx_sc_thermal.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series


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);
 			return -ENOMEM;
@@ -104,6 +105,7 @@  static int imx_sc_thermal_probe(struct platform_device *pdev)
 				"failed to get valid sensor resource id: %d\n",
+			of_node_put(child);
@@ -113,6 +115,7 @@  static int imx_sc_thermal_probe(struct platform_device *pdev)
 		if (IS_ERR(sensor->tzd)) {
 			dev_err(&pdev->dev, "failed to register thermal zone\n");
+			of_node_put(child);
 			ret = PTR_ERR(sensor->tzd);