]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (pmbus/ina233) Add error check for pmbus_read_word_data() return value
authorSanman Pradhan <psanman@juniper.net>
Tue, 17 Mar 2026 17:46:31 +0000 (17:46 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 17 Mar 2026 22:21:36 +0000 (15:21 -0700)
ina233_read_word_data() uses the return value of pmbus_read_word_data()
directly in a DIV_ROUND_CLOSEST() computation without first checking for
errors. If the underlying I2C transaction fails, a negative error code is
used in the arithmetic, producing a garbage sensor value instead of
propagating the error.

Add the missing error check before using the return value.

Fixes: b64b6cb163f16 ("hwmon: Add driver for TI INA233 Current and Power Monitor")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260317174553.385567-1-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/ina233.c

index dde1e16783943a51f5c3984ee4f8dca0b05f23ba..2d8b5a5347edc3bbceb35f4ea8f618f391c798b0 100644 (file)
@@ -67,6 +67,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page,
        switch (reg) {
        case PMBUS_VIRT_READ_VMON:
                ret = pmbus_read_word_data(client, 0, 0xff, MFR_READ_VSHUNT);
+               if (ret < 0)
+                       return ret;
 
                /* Adjust returned value to match VIN coefficients */
                /* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */