Skip to content

Commit fb3cdf1

Browse files
rafaeljwsmb49
authored andcommitted
thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type()
BugLink: https://bugs.launchpad.net/bugs/2011226 [ 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> Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> Acked-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
1 parent 32cec7c commit fb3cdf1

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
@@ -80,11 +80,13 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
8080
enum thermal_trip_type *type)
8181
{
8282
struct int34x_thermal_zone *d = zone->devdata;
83-
int i;
83+
int i, ret = 0;
8484

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

88+
mutex_lock(&d->trip_mutex);
89+
8890
if (trip < d->aux_trip_nr)
8991
*type = THERMAL_TRIP_PASSIVE;
9092
else if (trip == d->crt_trip_id)
@@ -102,10 +104,12 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
102104
}
103105
}
104106
if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
105-
return -EINVAL;
107+
ret = -EINVAL;
106108
}
107109

108-
return 0;
110+
mutex_unlock(&d->trip_mutex);
111+
112+
return ret;
109113
}
110114

111115
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,

0 commit comments

Comments
 (0)