hwmon: pmbus: protect read-modify-write with lock
Subsystems (2)
PATCH 1/1 hwmon: pmbus: protect read-modify-write with lock
The operation done in the pmbus_update_fan() function is a read-modify-write operation but it lacks any kind of lock protection which may cause problems if run more than once simultaneously. This patch uses an existing update_lock mutex to fix this problem.
--- drivers/hwmon/pmbus/pmbus_core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +8 -3
@@ -268,6 +268,7 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id,int rv;u8 to; +mutex_lock (&data->update_lock); from =pmbus_read_byte_data (client, page, pmbus_fan_config_registers[id]);if (from <0 )
@@ -278,11 +279,15 @@ int pmbus_update_fan(struct i2c_client *client, int page, int id, rv =pmbus_write_byte_data (client, page, pmbus_fan_config_registers[id], to);if (rv <0 ) -return rv; + goto out; } -return _pmbus_write_word_data (client, page, - pmbus_fan_command_registers[id], command); + rv =_pmbus_write_word_data (client, page, + pmbus_fan_command_registers[id], command); + +out: +mutex_lock (&data->update_lock); +return rv; }EXPORT_SYMBOL_GPL (pmbus_update_fan);
Signature · 1 line
2.20.1
Quoted 6 lines · Krzysztof (Nokia - PL/Wroclaw)
The operation done in the
pmbus_update_fan()function is a read-modify-write operation but it lacks any kind of lock protection which may cause problems if run more than once simultaneously. This patch uses an existingupdate_lockmutex to fix this problem.Signed-off-by Krzysztof Adamski <[email protected]>
Please use get_maintainer to find the people responsible for this file. It is not my realm.
drivers/hwmon/pmbus/pmbus_core.c int pmbus_update_fan(struct i2c_client *client, int page, int id, · line 289
Quoted 2 lines
drivers/hwmon/pmbus/pmbus_core.c +2
-0+out: +mutex_lock (&data->update_lock);
Despite the above, have you tested the code? This likely should be mutex_unlock?
Quoted 8 lines · Wolfram Sang
Quoted 6 lines · Krzysztof (Nokia - PL/Wroclaw)
The operation done in the
pmbus_update_fan()function is a read-modify-write operation but it lacks any kind of lock protection which may cause problems if run more than once simultaneously. This patch uses an existingupdate_lockmutex to fix this problem.Signed-off-by Krzysztof Adamski <[email protected]>
Quoted 9 lines
Please use
get_maintainerto find the people responsible for this file. It is not my realm.drivers/hwmon/pmbus/pmbus_core.c int pmbus_update_fan(struct i2c_client *client, int page, int id, · line 289
Quoted 2 lines
drivers/hwmon/pmbus/pmbus_core.c +2
-0+out: +mutex_lock (&data->update_lock);Despite the above, have you tested the code? This likely should be
mutex_unlock?
Sorry for that, I made a mistake and used wrong command to generate the patch and send it to the wrong list of people. You can ignore this patchset, it was resent to the proper mailing list instead.
Krzysztof
Hi Krzysztof,
Quoted 2 lines
patch and send it to the wrong list of people. You can ignore this patchset, it was resent to the proper mailing list instead.
Thanks for the heads up.
Regards,
Wolfram