hwmon: (pmbus/core) Avoid race condition during probe
Guenter Roeck
maintainerPATCH 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")
Signed-off-by Guenter Roeck <[email protected]>
--- drivers/hwmon/pmbus/pmbus_core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwmon/pmbus/pmbus_core.c +4 -0
@@ -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
[email protected]
AI reviewSashiko 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")Signed-off-by Guenter Roeck <[email protected]>
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