From: sashiko-bot@kernel.org
To: "Luiz Angelo Daros de Luca" <luizluca@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [hwmon PATCH v2 3/8] hwmon: (adt7470) Fix busy-loop and I2C flooding in update thread
Date: Tue, 28 Jul 2026 00:37:47 +0000 [thread overview]
Message-ID: <20260728003747.B67731F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-adt7470_fixes-v2-3-598e38a46ba6@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Setting `num_temp_sensors` to a non-negative value before temperatures have been probed permanently breaks temperature reporting and stalls sysfs reads.
--
--- Patch [3]: [hwmon PATCH v2 3/8] hwmon: (adt7470) Fix busy-loop and I2C flooding in update thread ---
commit 34430e742760a7d00b9b258ac39d10dadd63f0d0
Author: Luiz Angelo Daros de Luca <luizluca@gmail.com>
hwmon: (adt7470) Fix busy-loop and I2C flooding in update thread
This commit fixes a busy-loop vulnerability in the background thread.
It clamps the minimum auto_update_interval to 500ms to guarantee a
reasonable minimum sleep window between sensor updates.
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/r/20260716213252.EACA71F000E9@smtp.kernel.org
Fixes: 89fac11cb3e7 ("adt7470: make automatic fan control really work")
> diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
> index 62ec68ea0a406..0b19b0925d1c7 100644
> --- a/drivers/hwmon/adt7470.c
> +++ b/drivers/hwmon/adt7470.c
> @@ -509,7 +509,7 @@ static ssize_t auto_update_interval_store(struct device *dev,
> if (kstrtol(buf, 10, &temp))
> return -EINVAL;
>
> - temp = clamp_val(temp, 0, 60000);
> + temp = clamp_val(temp, 500, 60000);
>
> mutex_lock(&data->lock);
> data->auto_update_interval = temp;
[Severity: High]
This is a pre-existing issue, but does setting num_temp_sensors before
temperatures are probed prevent temperature reporting and stall sysfs reads?
If userspace writes a non-negative value to the num_temp_sensors sysfs node
before data->temperatures_probed is set to 1, data->temperatures_probed
remains 0:
drivers/hwmon/adt7470.c:num_temp_sensors_store() {
...
data->num_temp_sensors = temp;
if (temp < 0)
data->temperatures_probed = 0;
...
}
Because temperatures_probed is 0, adt7470_update_sensors() will always call
adt7470_read_temperatures() rather than a bulk read. Inside
adt7470_read_temperatures(), it checks the sensor count:
drivers/hwmon/adt7470.c:adt7470_read_temperatures() {
...
/* Only count fans if we have to */
if (data->num_temp_sensors >= 0)
return 0;
err = regmap_bulk_read(data->regmap, ADT7470_TEMP_REG(0),
&data->temp[0], ADT7470_TEMP_COUNT);
...
data->temperatures_probed = 1;
return 0;
}
Since num_temp_sensors >= 0, it returns early and never actually reads the
temperature registers or sets data->temperatures_probed = 1. This appears to
cause every subsequent sensor update to stall the driver with the probe sleep
time while never actually updating data->temp.
Could num_temp_sensors_store() also set data->temperatures_probed = 1 when
temp >= 0, or should adt7470_read_temperatures() read the registers
regardless of the num_temp_sensors value?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-adt7470_fixes-v2-0-598e38a46ba6@gmail.com?part=3
next prev parent reply other threads:[~2026-07-28 0:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 0:22 [hwmon PATCH v2 0/8] hwmon: (adt7470): Multiple fixes Luiz Angelo Daros de Luca
2026-07-28 0:22 ` [hwmon PATCH v2 1/8] hwmon: (adt7470) Fix fans stuck in manual mode on I2C errors Luiz Angelo Daros de Luca
2026-07-28 0:30 ` sashiko-bot
2026-07-28 0:53 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 2/8] hwmon: (adt7470) Fix cache updated before hardware write on I2C error Luiz Angelo Daros de Luca
2026-07-28 0:34 ` sashiko-bot
2026-07-28 0:54 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 3/8] hwmon: (adt7470) Fix busy-loop and I2C flooding in update thread Luiz Angelo Daros de Luca
2026-07-28 0:37 ` sashiko-bot [this message]
2026-07-28 0:55 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 4/8] hwmon: (adt7470) Fix swapped PWM3 and PWM4 auto mode masks Luiz Angelo Daros de Luca
2026-07-28 0:34 ` sashiko-bot
2026-07-28 0:57 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 5/8] hwmon: (adt7470) Fix temperature alarm logic in hwmon_temp_read() Luiz Angelo Daros de Luca
2026-07-28 0:32 ` sashiko-bot
2026-07-28 0:55 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 6/8] hwmon: (adt7470) Use cached PWM frequency value Luiz Angelo Daros de Luca
2026-07-28 0:36 ` sashiko-bot
2026-07-28 0:51 ` Guenter Roeck
2026-07-28 0:57 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 7/8] hwmon: (adt7470) Fix divide-by-zero TOCTOU crash in fan speed read Luiz Angelo Daros de Luca
2026-07-28 0:37 ` sashiko-bot
2026-07-28 0:58 ` Guenter Roeck
2026-07-28 0:22 ` [hwmon PATCH v2 8/8] hwmon: (adt7470) Fix PWM auto temp state array and bounds check Luiz Angelo Daros de Luca
2026-07-28 0:40 ` sashiko-bot
2026-07-28 0:58 ` Guenter Roeck
2026-07-28 1:04 ` [hwmon PATCH v2 0/8] hwmon: (adt7470): Multiple fixes Guenter Roeck
2026-07-28 1:08 ` Luiz Angelo Daros de Luca
2026-07-28 3:35 ` Guenter Roeck
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=20260728003747.B67731F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=luizluca@gmail.com \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox