===================================================================
@@ -728,6 +728,7 @@ struct thermal_zone_device *thermal_zone
mutex_lock(&thermal_list_lock);
list_for_each_entry(tz, &thermal_tz_list, node) {
if (tz->id == id) {
+ get_device(&tz->device);
match = tz;
break;
}
===================================================================
@@ -194,6 +194,11 @@ int for_each_thermal_governor(int (*cb)(
struct thermal_zone_device *thermal_zone_get_by_id(int id);
+static inline void thermal_zone_put(struct thermal_zone_device *tz)
+{
+ put_device(&tz->device);
+}
+
static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
{
return cdev->ops->get_requested_power && cdev->ops->state2power &&
===================================================================
@@ -445,7 +445,7 @@ static int thermal_genl_cmd_tz_get_trip(
const struct thermal_trip_desc *td;
struct thermal_zone_device *tz;
struct nlattr *start_trip;
- int id;
+ int id, ret = -EMSGSIZE;
if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
return -EINVAL;
@@ -458,7 +458,7 @@ static int thermal_genl_cmd_tz_get_trip(
start_trip = nla_nest_start(msg, THERMAL_GENL_ATTR_TZ_TRIP);
if (!start_trip)
- return -EMSGSIZE;
+ goto out_put;
mutex_lock(&tz->lock);
@@ -470,19 +470,20 @@ static int thermal_genl_cmd_tz_get_trip(
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) ||
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip->temperature) ||
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip->hysteresis))
- goto out_cancel_nest;
+ goto out_unlock;
}
- mutex_unlock(&tz->lock);
-
nla_nest_end(msg, start_trip);
- return 0;
+ ret = 0;
-out_cancel_nest:
+out_unlock:
mutex_unlock(&tz->lock);
- return -EMSGSIZE;
+out_put:
+ thermal_zone_put(tz);
+
+ return ret;
}
static int thermal_genl_cmd_tz_get_temp(struct param *p)
@@ -501,6 +502,9 @@ static int thermal_genl_cmd_tz_get_temp(
return -EINVAL;
ret = thermal_zone_get_temp(tz, &temp);
+
+ thermal_zone_put(tz);
+
if (ret)
return ret;
@@ -535,6 +539,8 @@ static int thermal_genl_cmd_tz_get_gov(s
mutex_unlock(&tz->lock);
+ thermal_zone_put(tz);
+
return ret;
}