Skip to contentSkip to conversation

hwmon: (pmbus/core) Avoid race condition during probe

PATCH New Guenter Roeck 2 participants 2 messages Aug 3 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (pmbus/core) Avoid race condition during probe

pmbus_write_smbalert_mask() is not guarded, which can cause race conditions with concurrent sysfs attribute accesses.

Similar, PMBus accesses in pmbus_init_debugfs() are not guarded, also resulting in potential race conditions.

Add guards to both functions to prevent the races.

Fixes 221819ca4c36e ("hwmon: (pmbus/core) Add interrupt support")
Fixes 1e069dfd96dfe ("hwmon: (pmbus) Add debugfs for status registers")
---
 drivers/hwmon/pmbus/pmbus_core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hwmon/pmbus/pmbus_core.c +4 -0
index ba3e9e9fc8bc..6991c7f8d125 100644
@@ -3448,6 +3448,8 @@ static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg,
 {
 	int ret;
 
+	guard(pmbus_lock)(client);
+
 	ret = _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8));
 
 	/*
@@ -3700,6 +3702,8 @@ static void pmbus_init_debugfs(struct i2c_client *client,
 	if (!entries)
 		return;
 
+	guard(pmbus_lock)(client);
+
 	/*
 	 * Add device-specific entries.
 	 * Please note that the PMBUS standard allows all registers to be
Signature · 1 line
2.45.2
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines

pmbus_write_smbalert_mask() is not guarded, which can cause race conditions with concurrent sysfs attribute accesses.

Similar, PMBus accesses in pmbus_init_debugfs() are not guarded, also resulting in potential race conditions.

Add guards to both functions to prevent the races.

Fixes 221819ca4c36e ("hwmon: (pmbus/core) Add interrupt support")
Fixes 1e069dfd96dfe ("hwmon: (pmbus) Add debugfs for status registers")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1