Unverified Commit 597b1933 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12718 thermal: core: Reference count the zone in thermal_zone_get_by_id()

parents a1eda839 8ef588aa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -582,6 +582,7 @@ struct thermal_zone_device *thermal_zone_get_by_id(int id)
	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;
		}
+3 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),

struct thermal_zone_device *thermal_zone_get_by_id(int id);

DEFINE_CLASS(thermal_zone_get_by_id, struct thermal_zone_device *,
	     if (_T) put_device(&_T->device), thermal_zone_get_by_id(id), int id)

struct thermal_attr {
	struct device_attribute attr;
	char name[THERMAL_NAME_LENGTH];
+3 −6
Original line number Diff line number Diff line
@@ -450,7 +450,6 @@ static int thermal_genl_cmd_tz_get_id(struct param *p)
static int thermal_genl_cmd_tz_get_trip(struct param *p)
{
	struct sk_buff *msg = p->msg;
	struct thermal_zone_device *tz;
	struct nlattr *start_trip;
	struct thermal_trip trip;
	int ret, i, id;
@@ -460,7 +459,7 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)

	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);

	tz = thermal_zone_get_by_id(id);
	CLASS(thermal_zone_get_by_id, tz)(id);
	if (!tz)
		return -EINVAL;

@@ -498,7 +497,6 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
static int thermal_genl_cmd_tz_get_temp(struct param *p)
{
	struct sk_buff *msg = p->msg;
	struct thermal_zone_device *tz;
	int temp, ret, id;

	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
@@ -506,7 +504,7 @@ static int thermal_genl_cmd_tz_get_temp(struct param *p)

	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);

	tz = thermal_zone_get_by_id(id);
	CLASS(thermal_zone_get_by_id, tz)(id);
	if (!tz)
		return -EINVAL;

@@ -524,7 +522,6 @@ static int thermal_genl_cmd_tz_get_temp(struct param *p)
static int thermal_genl_cmd_tz_get_gov(struct param *p)
{
	struct sk_buff *msg = p->msg;
	struct thermal_zone_device *tz;
	int id, ret = 0;

	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
@@ -532,7 +529,7 @@ static int thermal_genl_cmd_tz_get_gov(struct param *p)

	id = nla_get_u32(p->attrs[THERMAL_GENL_ATTR_TZ_ID]);

	tz = thermal_zone_get_by_id(id);
	CLASS(thermal_zone_get_by_id, tz)(id);
	if (!tz)
		return -EINVAL;