Skip to content

Commit 19d4b9c

Browse files
Sanman Pradhangroeck
authored andcommitted
hwmon: (pmbus/mp2975) Add error check for pmbus_read_word_data() return value
mp2973_read_word_data() XORs the return value of pmbus_read_word_data() with PB_STATUS_POWER_GOOD_N without first checking for errors. If the I2C transaction fails, a negative error code is XORed with the constant, producing a corrupted value that is returned as valid status data instead of propagating the error. Add the missing error check before modifying the return value. Fixes: acda945 ("hwmon: (pmbus/mp2975) Fix PGOOD in READ_STATUS_WORD") 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 c925fcc commit 19d4b9c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hwmon/pmbus/mp2975.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ static int mp2973_read_word_data(struct i2c_client *client, int page,
313313
case PMBUS_STATUS_WORD:
314314
/* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */
315315
ret = pmbus_read_word_data(client, page, phase, reg);
316+
if (ret < 0)
317+
return ret;
316318
ret ^= PB_STATUS_POWER_GOOD_N;
317319
break;
318320
case PMBUS_OT_FAULT_LIMIT:

0 commit comments

Comments
 (0)