Skip to contentSkip to conversation

thermal: imx_sc_thermal: drop child node when break loop

PATCH New Pan Bian 1 participant 1 message Jan 22, 2021

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 thermal: imx_sc_thermal: drop child node when break loop

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")
---
 drivers/thermal/imx_sc_thermal.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/thermal/imx_sc_thermal.c +3 -0
index b01d28eca7ee..404cab7221e3 100644
@@ -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;
 		}
Signature · 8 lines
2.17.1



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