Re: [PATCH v2 4/6] hwmon: (lm63) Add Sensylink CTF2301 support

"Troy Mitchell" <[email protected]> Tue, 21 Jul 2026 04:52:12 -0700
Newsgroups dev.linux.lists.spacemit,org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue, Jul 21, 2026 at 10:00:04AM +0000, [email protected] wrote:
> [Severity: Medium]
> Will this corrupt the temperature reading if the I2C read fails?
>
> In lm63_update_device(), if i2c_smbus_read_byte_data() for the LSB returns
> a negative error code (such as -EIO), it gets bitwise-ORed with the shifted
> MSB. The negative s32 error code would sign-extend, overwriting the MSB
> bits entirely and resulting in a large negative temperature spike instead
> of propagating the error or maintaining the previous valid reading.
>
> Could we check the return value of i2c_smbus_read_byte_data() before
> merging it into temp1_input and temp1_max?

Good catch. A failed read must not be combined with the other temperature
byte. I will read both bytes into temporary integers, check both return
values, and update the cached 12-bit value only after both reads succeed.

The existing lm63_update_device() also truncates or combines unchecked
i2c_smbus_read_byte_data() results in several other paths. I will address
those existing error-handling issues in a separate patch, rather than mix
that broader change into the CTF2301 support patch.

                                            - Troy