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 8/8] hwmon: (adt7470) Fix PWM auto temp state array and bounds check
Date: Tue, 28 Jul 2026 00:40:14 +0000 [thread overview]
Message-ID: <20260728004014.94FCC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-adt7470_fixes-v2-8-598e38a46ba6@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The driver violates HWMON subsystem guidelines by using a private mutex (`data->lock`) instead of the required `hwmon_lock()` API to serialize sysfs attributes registered outside the `info` structure.
--
--- Patch [8]: [hwmon PATCH v2 8/8] hwmon: (adt7470) Fix PWM auto temp state array and bounds check ---
commit 3702a967e9e4da59d546cf6a3b0fc208ec5ff2bf
Author: Luiz Angelo Daros de Luca <luizluca@gmail.com>
hwmon: (adt7470) Fix PWM auto temp state array and bounds check
This commit fixes a bounds checking issue in pwm_auto_temp_store() where
values > 0xF could overflow into adjacent channel bits. It also corrects
the array assignment so values are written to pwm_auto_temp instead of
pwm_automatic after a successful I2C write.
Closes: https://lore.kernel.org/all/20260727034932.0B7C41F000E9@smtp.kernel.org/#t
> diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
> index 772d2a409bb5c..c45b984c02e6b 100644
> --- a/drivers/hwmon/adt7470.c
> +++ b/drivers/hwmon/adt7470.c
> @@ -1049,8 +1049,10 @@ static ssize_t pwm_auto_temp_store(struct device *dev,
> if (temp < 0)
> return temp;
>
> + if (temp > 0xF)
> + return -EINVAL;
> +
> mutex_lock(&data->lock);
[Severity: High]
This is a pre-existing issue, but does this driver violate the hwmon
subsystem locking guidelines by using a private mutex here?
According to the hardware monitoring API documentation, drivers must
implement locking required for interrupt handling and for attributes
registered outside the standard info structure using hwmon_lock() and
hwmon_unlock(). The core relies on this to serialize thermal subsystem
and sysfs operations.
By using the private data->lock in pwm_auto_temp_store(), could this
bypass the central hwmon locking mechanism and cause concurrency issues
with the thermal subsystem?
Would it make sense to update this to use hwmon_lock(dev)?
> - data->pwm_automatic[attr->index] = temp;
>
> if (!(attr->index % 2)) {
> mask = 0xF0;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-adt7470_fixes-v2-0-598e38a46ba6@gmail.com?part=8
next prev parent reply other threads:[~2026-07-28 0:40 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
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 [this message]
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=20260728004014.94FCC1F000E9@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 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.