Skip to content

Commit 8625955

Browse files
Sanman Pradhangroeck
authored andcommitted
hwmon: (pmbus/isl68137) Fix unchecked return value and use sysfs_emit()
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: [email protected] Signed-off-by: Sanman Pradhan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 32f5930 commit 8625955

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
@@ -98,8 +98,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
9898
{
9999
int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
100100

101-
return sprintf(buf, "%d\n",
102-
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
101+
if (val < 0)
102+
return val;
103+
104+
return sysfs_emit(buf, "%d\n",
105+
(val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS);
103106
}
104107

105108
static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,

0 commit comments

Comments
 (0)