hwmon: (gpio-fan) Add missing mutex locks
[ Upstream commit 9fee7d19bab635f89223cc40dfd2c8797fdc4988 ] set_fan_speed() is expected to be called with fan_data->lock being locked. Add locking for proper synchronization. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Link: https://lore.kernel.org/r/20250210145934.761280-3-alexander.stein@ew.tq-group.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org> [uli: backport to 4.19] Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
3fba5e3ce3
commit
cd778bb670
@@ -407,7 +407,12 @@ static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
|
||||
if (state >= fan_data->num_speed)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&fan_data->lock);
|
||||
|
||||
set_fan_speed(fan_data, state);
|
||||
|
||||
mutex_unlock(&fan_data->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -563,8 +568,11 @@ static int gpio_fan_remove(struct platform_device *pdev)
|
||||
if (!IS_ERR(fan_data->cdev))
|
||||
thermal_cooling_device_unregister(fan_data->cdev);
|
||||
|
||||
if (fan_data->gpios)
|
||||
if (fan_data->gpios) {
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(fan_data, 0);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -581,7 +589,9 @@ static int gpio_fan_suspend(struct device *dev)
|
||||
|
||||
if (fan_data->gpios) {
|
||||
fan_data->resume_speed = fan_data->speed_index;
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(fan_data, 0);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -591,8 +601,11 @@ static int gpio_fan_resume(struct device *dev)
|
||||
{
|
||||
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
||||
|
||||
if (fan_data->gpios)
|
||||
if (fan_data->gpios) {
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(fan_data, fan_data->resume_speed);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user