Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Krzysztof Kozlowski and committed by
Daniel Lezcano
3da97620 3ae5950d

+3
+3
drivers/thermal/imx_sc_thermal.c
··· 93 93 for_each_available_child_of_node(np, child) { 94 94 sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL); 95 95 if (!sensor) { 96 + of_node_put(child); 96 97 of_node_put(sensor_np); 97 98 return -ENOMEM; 98 99 } ··· 105 104 dev_err(&pdev->dev, 106 105 "failed to get valid sensor resource id: %d\n", 107 106 ret); 107 + of_node_put(child); 108 108 break; 109 109 } 110 110 ··· 116 114 if (IS_ERR(sensor->tzd)) { 117 115 dev_err(&pdev->dev, "failed to register thermal zone\n"); 118 116 ret = PTR_ERR(sensor->tzd); 117 + of_node_put(child); 119 118 break; 120 119 } 121 120