diff options
| author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2023-01-25 13:17:42 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-22 12:47:16 +0100 |
| commit | 6a73a0e3eddb7ffc50febb3afd172f88c1340961 (patch) | |
| tree | 040e85e659fddee92f8c6e8ff751dcff8f36f01d | |
| parent | 81f0e0be230792cd5779333feadd06ad7c820ef3 (diff) | |
| download | linux-6a73a0e3eddb7ffc50febb3afd172f88c1340961.tar.gz linux-6a73a0e3eddb7ffc50febb3afd172f88c1340961.tar.bz2 linux-6a73a0e3eddb7ffc50febb3afd172f88c1340961.zip | |
thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
commit acd7e9ee57c880b99671dd99680cb707b7b5b0ee upstream.
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: 6757a7abe47b ("thermal: intel: int340x: Protect trip temperature from concurrent updates")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/thermal/int340x_thermal/int340x_thermal_zone.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c index d3829308560c..1adcef95f7b9 100644 --- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c @@ -89,11 +89,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) @@ -111,10 +113,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, |
