Skip to content

Commit 873e919

Browse files
committed
hwmon: (lm90) Add lock protection to lm90_alert
Sashiko reports: lm90_alert() executes in the smbus alert context and calls lm90_update_confreg() to disable the hardware alert line, without acquiring hwmon_lock. Concurrently, sysfs write operations (such as lm90_write_convrate) hold the hwmon_lock, temporarily modify data->config, and then restore it. If an alert interrupt occurs concurrently with a sysfs write, the sysfs path will overwrite the alert handler's modifications to data->config and the hardware register. This unintentionally re-enables the hardware alert line while the alarm is still active, causing an interrupt storm. Add the missing lock to lm90_alert() to solve the problem. Fixes: 7a1d220 ("hwmon: (lm90) Introduce function to update configuration register") Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent b09a456 commit 873e919

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hwmon/lm90.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
29462946
*/
29472947
struct lm90_data *data = i2c_get_clientdata(client);
29482948

2949+
hwmon_lock(data->hwmon_dev);
29492950
if (!data->shutdown && (data->flags & LM90_HAVE_BROKEN_ALERT) &&
29502951
(data->current_alarms & data->alert_alarms)) {
29512952
if (!(data->config & 0x80)) {
@@ -2955,6 +2956,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
29552956
schedule_delayed_work(&data->alert_work,
29562957
max_t(int, HZ, msecs_to_jiffies(data->update_interval)));
29572958
}
2959+
hwmon_unlock(data->hwmon_dev);
29582960
} else {
29592961
dev_dbg(&client->dev, "Everything OK\n");
29602962
}

0 commit comments

Comments
 (0)