@@ -373,7 +373,7 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz,
int (*action)(struct device_node *, int, int,
struct thermal_zone_device *, struct thermal_cooling_device *))
{
- struct device_node *tz_np, *cm_np, *child;
+ struct device_node *tz_np, *cm_np;
int ret = 0;
tz_np = thermal_of_zone_get_by_name(tz);
@@ -386,12 +386,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz,
if (!cm_np)
goto out;
- for_each_child_of_node(cm_np, child) {
+ for_each_child_of_node_scoped(cm_np, child) {
ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action);
- if (ret) {
- of_node_put(child);
+ if (ret)
break;
- }
}
of_node_put(cm_np);