Commit 873e919e authored by Guenter Roeck's avatar Guenter Roeck
Browse files

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: 7a1d220c ("hwmon: (lm90) Introduce function to update configuration register")
Reported-by: default avatarSashiko <sashiko-bot@kernel.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent b09a4560
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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");
	}