Skip to content

Commit

Permalink
thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
Browse files Browse the repository at this point in the history
[ Upstream commit acd7e9e ]

In order to prevent int340x_thermal_get_trip_type() from possibly
racing with int340x_thermal_read_trips() invoked by int3403_notify()
add locking to it in analogy with int340x_thermal_get_trip_temp().

Fixes: 6757a7a ("thermal: intel: int340x: Protect trip temperature from concurrent updates")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
rafaeljw authored and gregkh committed Feb 1, 2023
1 parent a8f2ee1 commit 76d1302
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
Expand Up @@ -81,11 +81,13 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
enum thermal_trip_type *type)
{
struct int34x_thermal_zone *d = zone->devdata;
int i;
int i, ret = 0;

if (d->override_ops && d->override_ops->get_trip_type)
return d->override_ops->get_trip_type(zone, trip, type);

mutex_lock(&d->trip_mutex);

if (trip < d->aux_trip_nr)
*type = THERMAL_TRIP_PASSIVE;
else if (trip == d->crt_trip_id)
Expand All @@ -103,10 +105,12 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
}
}
if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
return -EINVAL;
ret = -EINVAL;
}

return 0;
mutex_unlock(&d->trip_mutex);

return ret;
}

static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
Expand Down

0 comments on commit 76d1302

Please sign in to comment.