From: "Troy Mitchell" <troy.mitchell@linux.dev>
To: "Troy Mitchell" <troy.mitchell@linux.dev>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>, "Yixun Lan" <dlan@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>
Cc: <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-hwmon@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
<spacemit@lists.linux.dev>, <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 4/6] hwmon: (lm63) Add Sensylink CTF2301 support
Date: Tue, 21 Jul 2026 04:52:12 -0700 [thread overview]
Message-ID: <DK487PYQKFZK.HX96HW3B22XZ@linux.dev> (raw)
In-Reply-To: <20260721100004.D93AC1F000E9@smtp.kernel.org>
On Tue, Jul 21, 2026 at 10:00:04AM +0000, sashiko-bot@kernel.org 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
WARNING: multiple messages have this Message-ID (diff)
From: "Troy Mitchell" <troy.mitchell@linux.dev>
To: "Troy Mitchell" <troy.mitchell@linux.dev>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>, "Yixun Lan" <dlan@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>
Cc: <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-hwmon@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
<spacemit@lists.linux.dev>, <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 4/6] hwmon: (lm63) Add Sensylink CTF2301 support
Date: Tue, 21 Jul 2026 04:52:12 -0700 [thread overview]
Message-ID: <DK487PYQKFZK.HX96HW3B22XZ@linux.dev> (raw)
In-Reply-To: <20260721100004.D93AC1F000E9@smtp.kernel.org>
On Tue, Jul 21, 2026 at 10:00:04AM +0000, sashiko-bot@kernel.org 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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-07-21 11:52 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 9:48 [PATCH v2 0/6] hwmon: (lm63) Add Sensylink CTF2301 support Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 9:48 ` [PATCH v2 1/6] dt-bindings: vendor-prefixes: Add Sensylink Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 9:51 ` sashiko-bot
2026-07-21 15:49 ` Conor Dooley
2026-07-21 15:49 ` Conor Dooley
2026-07-21 17:56 ` Guenter Roeck
2026-07-21 17:56 ` Guenter Roeck
2026-07-21 9:48 ` [PATCH v2 2/6] dt-bindings: hwmon: Move LM63 family to a dedicated binding Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 9:58 ` sashiko-bot
2026-07-21 11:38 ` Troy Mitchell
2026-07-21 11:38 ` Troy Mitchell
2026-07-21 9:48 ` [PATCH v2 3/6] dt-bindings: hwmon: Add Sensylink CTF2301 Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 9:57 ` sashiko-bot
2026-07-21 15:46 ` Conor Dooley
2026-07-21 15:46 ` Conor Dooley
2026-07-21 9:48 ` [PATCH v2 4/6] hwmon: (lm63) Add Sensylink CTF2301 support Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 10:00 ` sashiko-bot
2026-07-21 11:52 ` Troy Mitchell [this message]
2026-07-21 11:52 ` Troy Mitchell
2026-07-21 9:48 ` [PATCH v2 5/6] riscv: dts: spacemit: Add K3 I2C6 pinctrl state Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 10:00 ` sashiko-bot
2026-07-21 11:52 ` Troy Mitchell
2026-07-21 11:52 ` Troy Mitchell
2026-07-21 9:48 ` [PATCH v2 6/6] riscv: dts: spacemit: Add CTF2301 on K3 CoM260 Troy Mitchell
2026-07-21 9:48 ` Troy Mitchell
2026-07-21 10:00 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DK487PYQKFZK.HX96HW3B22XZ@linux.dev \
--to=troy.mitchell@linux.dev \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlan@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@roeck-us.net \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=spacemit@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.