]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (pmbus/max31785) check for partial i2c_transfer in read_long_data
authorSanman Pradhan <psanman@juniper.net>
Sat, 21 Mar 2026 18:12:05 +0000 (18:12 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:06 +0000 (19:45 -0700)
commit80306ba88ba6891f8cd16d4042beec69e9044de7
tree0a069b0aef8531c4dc610517d5674d6eec49635b
parent6be9b04ef3fff87bf329fecae4647196ffefc539
hwmon: (pmbus/max31785) check for partial i2c_transfer in read_long_data

i2c_transfer() returns the number of messages successfully
transferred, not only a negative errno on failure. When called with
two messages (write command byte followed by a read of the 4-byte
response), a return value of 1 means the command write succeeded but
the read did not complete. In that case, rspbuf remains uninitialized
and must not be interpreted as valid data.

Treat any return value other than ARRAY_SIZE(msg) as an error, and
return -EIO for partial completion. Also return 0 on success instead
of the message count, since the caller only needs to distinguish
success from failure.

Signed-off-by: Sanman Pradhan <psanman@juniper.net>
Link: https://lore.kernel.org/r/20260321181052.27129-4-sanman.pradhan@hpe.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/max31785.c