Commit 86259558 authored by Sanman Pradhan's avatar Sanman Pradhan Committed by Guenter Roeck
Browse files

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: 038a9c3d ("hwmon: (pmbus/isl68137) Add driver for Intersil ISL68137 PWM Controller")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260318193952.47908-2-sanman.pradhan@hpe.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 32f59301
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -98,8 +98,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
{
	int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);

	return sprintf(buf, "%d\n",
		       (val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
	if (val < 0)
		return val;

	return sysfs_emit(buf, "%d\n",
			   (val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS);
}

static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,