Skip to content

Commit 4418f31

Browse files
Sanman Pradhangregkh
authored andcommitted
hwmon: (pmbus/ina233) Add error check for pmbus_read_word_data() return value
commit 32f59301b9898c0ab5e72908556d553e2d481945 upstream. 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: b64b6cb ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent beab26d commit 4418f31

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/hwmon/pmbus/ina233.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page,
6767
switch (reg) {
6868
case PMBUS_VIRT_READ_VMON:
6969
ret = pmbus_read_word_data(client, 0, 0xff, MFR_READ_VSHUNT);
70+
if (ret < 0)
71+
return ret;
7072

7173
/* Adjust returned value to match VIN coefficients */
7274
/* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */

0 commit comments

Comments
 (0)