Skip to content

Commit acd7e9e

Browse files
committed
thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
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>
1 parent 6757a7a commit acd7e9e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
8181
enum thermal_trip_type *type)
8282
{
8383
struct int34x_thermal_zone *d = zone->devdata;
84-
int i;
84+
int i, ret = 0;
8585

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

89+
mutex_lock(&d->trip_mutex);
90+
8991
if (trip < d->aux_trip_nr)
9092
*type = THERMAL_TRIP_PASSIVE;
9193
else if (trip == d->crt_trip_id)
@@ -103,10 +105,12 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
103105
}
104106
}
105107
if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
106-
return -EINVAL;
108+
ret = -EINVAL;
107109
}
108110

109-
return 0;
111+
mutex_unlock(&d->trip_mutex);
112+
113+
return ret;
110114
}
111115

112116
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,

0 commit comments

Comments
 (0)