]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
hwmon: (pmbus/mp2975) Add error check for pmbus_read_word_data() return value
authorSanman Pradhan <psanman@juniper.net>
Tue, 17 Mar 2026 17:37:17 +0000 (17:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:55 +0000 (11:08 +0100)
commit 19d4b9c8a136704d5f2544e7ac550f27918a5004 upstream.

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: acda945afb465 ("hwmon: (pmbus/mp2975) Fix PGOOD in READ_STATUS_WORD")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260317173308.382545-3-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/pmbus/mp2975.c

index 280bb12f762c3dc1d08350a1cf49395ef9c6b6d4..e26f09596a9460f8b6b6d9b21b092d893d152807 100644 (file)
@@ -313,6 +313,8 @@ static int mp2973_read_word_data(struct i2c_client *client, int page,
        case PMBUS_STATUS_WORD:
                /* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */
                ret = pmbus_read_word_data(client, page, phase, reg);
+               if (ret < 0)
+                       return ret;
                ret ^= PB_STATUS_POWER_GOOD_N;
                break;
        case PMBUS_OT_FAULT_LIMIT: