Skip to content

Commit 3da9762

Browse files
krzkdlezcano
authored andcommitted
thermal/drivers/imx_sc: Add missing of_node_put for loop iteration
Early exits from for_each_available_child_of_node() should decrement the node reference counter. Reported by Coccinelle: drivers/thermal/imx_sc_thermal.c:93:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 97. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Jacky Bai <ping.bai@nxp.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20210614192230.19248-1-krzysztof.kozlowski@canonical.com
1 parent 3ae5950 commit 3da9762

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/thermal/imx_sc_thermal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
9393
for_each_available_child_of_node(np, child) {
9494
sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL);
9595
if (!sensor) {
96+
of_node_put(child);
9697
of_node_put(sensor_np);
9798
return -ENOMEM;
9899
}
@@ -104,6 +105,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
104105
dev_err(&pdev->dev,
105106
"failed to get valid sensor resource id: %d\n",
106107
ret);
108+
of_node_put(child);
107109
break;
108110
}
109111

@@ -114,6 +116,7 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
114116
if (IS_ERR(sensor->tzd)) {
115117
dev_err(&pdev->dev, "failed to register thermal zone\n");
116118
ret = PTR_ERR(sensor->tzd);
119+
of_node_put(child);
117120
break;
118121
}
119122

0 commit comments

Comments
 (0)