@@ -96,10 +96,9 @@ static int thermal_of_populate_trip(struct device_node *np,
static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips)
{
struct thermal_trip *tt;
- struct device_node *trips;
int ret, count;
- trips = of_get_child_by_name(np, "trips");
+ struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips");
if (!trips) {
pr_err("Failed to find 'trips' node\n");
return ERR_PTR(-EINVAL);
@@ -108,15 +107,12 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
count = of_get_child_count(trips);
if (!count) {
pr_err("No trip point defined\n");
- ret = -EINVAL;
- goto out_of_node_put;
+ return ERR_PTR(-EINVAL);
}
tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
- if (!tt) {
- ret = -ENOMEM;
- goto out_of_node_put;
- }
+ if (!tt)
+ return ERR_PTR(-ENOMEM);
*ntrips = count;
@@ -127,15 +123,11 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
goto out_kfree;
}
- of_node_put(trips);
-
return tt;
out_kfree:
kfree(tt);
*ntrips = 0;
-out_of_node_put:
- of_node_put(trips);
return ERR_PTR(ret);
}