Skip to content

Commit c925fcc

Browse files
Sanman Pradhangroeck
authored andcommitted
hwmon: (pmbus/hac300s) Add error check for pmbus_read_word_data() return value
hac300s_read_word_data() passes the return value of pmbus_read_word_data() directly to FIELD_GET() without checking for errors. If the I2C transaction fails, a negative error code is sign-extended and passed to FIELD_GET(), which silently produces garbage data instead of propagating the error. Add the missing error check before using the return value in the FIELD_GET() macro. Fixes: 669cf16 ("hwmon: Add support for HiTRON HAC300S PSU") 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 f338e77 commit c925fcc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hwmon/pmbus/hac300s.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static int hac300s_read_word_data(struct i2c_client *client, int page,
5858
case PMBUS_MFR_VOUT_MIN:
5959
case PMBUS_READ_VOUT:
6060
rv = pmbus_read_word_data(client, page, phase, reg);
61+
if (rv < 0)
62+
return rv;
6163
return FIELD_GET(LINEAR11_MANTISSA_MASK, rv);
6264
default:
6365
return -ENODATA;

0 commit comments

Comments
 (0)