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

thermal/of: add missing of_node_put()

for_each_child_of_node performs an of_node_get on each
iteration, so a break out of the loop requires an
of_node_put.

This was done using the Coccinelle semantic patch
iterators/for_each_child.cocci

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Julia Lawall and committed by
Rafael J. Wysocki
8a81cf96 0bb80ecc

+6 -2
+6 -2
drivers/thermal/thermal_of.c
··· 37 37 */ 38 38 for_each_child_of_node(trips, t) { 39 39 40 - if (t == trip) 40 + if (t == trip) { 41 + of_node_put(t); 41 42 goto out; 43 + } 42 44 i++; 43 45 } 44 46 ··· 403 401 404 402 for_each_child_of_node(cm_np, child) { 405 403 ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action); 406 - if (ret) 404 + if (ret) { 405 + of_node_put(child); 407 406 break; 407 + } 408 408 } 409 409 410 410 of_node_put(cm_np);