]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (lm90) Add lock protection to lm90_alert
authorGuenter Roeck <linux@roeck-us.net>
Thu, 14 May 2026 21:41:00 +0000 (14:41 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sat, 16 May 2026 15:10:33 +0000 (08:10 -0700)
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: 7a1d220ccb0cc ("hwmon: (lm90) Introduce function to update configuration register")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm90.c

index c4a9dafff81d68089e1065781a204a0e55815255..1eeb608e59039d2654bb16f63add91497aeed548 100644 (file)
@@ -2946,6 +2946,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
                 */
                struct lm90_data *data = i2c_get_clientdata(client);
 
+               hwmon_lock(data->hwmon_dev);
                if (!data->shutdown && (data->flags & LM90_HAVE_BROKEN_ALERT) &&
                    (data->current_alarms & data->alert_alarms)) {
                        if (!(data->config & 0x80)) {
@@ -2955,6 +2956,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,
                        schedule_delayed_work(&data->alert_work,
                                max_t(int, HZ, msecs_to_jiffies(data->update_interval)));
                }
+               hwmon_unlock(data->hwmon_dev);
        } else {
                dev_dbg(&client->dev, "Everything OK\n");
        }