Skip to content

Commit 58b91c5

Browse files
Sanman Pradhangregkh
authored andcommitted
hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit()
commit 86259558e422b250aa6aa57163a6d759074573f5 upstream. isl68137_avs_enable_show_page() uses the return value of pmbus_read_byte_data() without checking for errors. If the I2C transaction fails, a negative error code is passed through bitwise operations, producing incorrect output. Add an error check to propagate the return value if it is negative. Additionally, modernize the callback by replacing sprintf() with sysfs_emit(). Fixes: 038a9c3 ("hwmon: (pmbus/isl68137) Add driver for Intersil ISL68137 PWM Controller") Cc: stable@vger.kernel.org Signed-off-by: Sanman Pradhan <psanman@juniper.net> Link: https://lore.kernel.org/r/20260318193952.47908-2-sanman.pradhan@hpe.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 81f61e3 commit 58b91c5

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/hwmon/pmbus/isl68137.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
9696
{
9797
int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
9898

99-
return sprintf(buf, "%d\n",
100-
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
99+
if (val < 0)
100+
return val;
101+
102+
return sysfs_emit(buf, "%d\n",
103+
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS);
101104
}
102105

103106
static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,

0 commit comments

Comments
 (0)