]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (pmbus/mp2869) Check pmbus_read_byte_data() before using its return value
authorSanman Pradhan <psanman@juniper.net>
Tue, 17 Mar 2026 17:37:41 +0000 (17:37 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 17 Mar 2026 22:20:55 +0000 (15:20 -0700)
commitc6f45ed26b6eb4766db06f21ff28a97ed485bcbb
tree29838962863d4abde464812cb00e40b3e5b85c83
parent19d4b9c8a136704d5f2544e7ac550f27918a5004
hwmon: (pmbus/mp2869) Check pmbus_read_byte_data() before using its return value

In mp2869_read_byte_data() and mp2869_read_word_data(), the return value
of pmbus_read_byte_data() for PMBUS_STATUS_MFR_SPECIFIC is used directly
inside FIELD_GET() macro arguments without error checking. If the I2C
transaction fails, a negative error code is passed to FIELD_GET() and
FIELD_PREP(), silently corrupting the status register bits being
constructed.

Extract the nested pmbus_read_byte_data() calls into a separate variable
and check for errors before use. This also eliminates a redundant duplicate
read of the same register in the PMBUS_STATUS_TEMPERATURE case.

Fixes: a3a2923aaf7f2 ("hwmon: add MP2869,MP29608,MP29612 and MP29816 series driver")
Cc: stable@vger.kernel.org
Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260317173308.382545-4-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/mp2869.c