From: sashiko-bot@kernel.org
To: "Sergio Melas" <sergiomelas@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 1/2] hwmon: (yogafan) Use u32 types and improve RLLag filter
Date: Fri, 17 Apr 2026 15:07:10 +0000 [thread overview]
Message-ID: <20260417150711.0CCE2C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260417142455.18806-1-sergiomelas@gmail.com>
Sashiko AI review found 1 potential issue(s):
- [High] Flawed ACPI fallback logic in `yoga_fan_read` causes cross-channel telemetry corruption and invalid handle evaluations.
--
commit d83c5a919208687dd832e2bb2139addf047ec4f5
Author: Sergio Melas <sergiomelas@gmail.com>
hwmon: (yogafan) Use u32 types and improve RLLag filter
This update transitions the driver to a Hardware Abstraction Layer (HAL)
to manage diverse EC behaviors across different hardware generations and
adds explicit WMI GUID detection.
> --- a/drivers/hwmon/yogafan.c
> +++ b/drivers/hwmon/yogafan.c
[ ... ]
> @@ -123,19 +187,58 @@ static int yoga_fan_read(struct device *dev, enum hwmon_sensor_types type,
> u32 attr, int channel, long *val)
> {
> struct yoga_fan_data *data = dev_get_drvdata(dev);
[ ... ]
> + /* 3. Hardware Reading with AND fallback logic */
> status = acpi_evaluate_integer(data->active_handles[channel], NULL, NULL, &raw_acpi);
> +
> + /* If the first attempt fails AND there is a second handle for that channel, */
> + /* try the second one */
> + if (ACPI_FAILURE(status) && cfg->paths[channel + 1])
> + status = acpi_evaluate_integer(data->active_handles[channel + 1],
> + NULL, NULL, &raw_acpi);
Does this fallback logic inadvertently access the wrong fan channel or
out-of-bounds memory?
During probe, active_handles is populated densely with successful ACPI
handles for each fan. For multi-fan setups, active_handles[1] corresponds
to the second fan. If reading the first fan (channel 0) fails, this fallback
will read active_handles[1]. Could this result in reporting Fan 2's speed
as Fan 1's speed?
Additionally, in single-fan setups where probe stops after finding one fan,
active_handles[1] remains uninitialized (NULL). If the read for channel 0
fails, and cfg->paths[1] is populated, this will pass NULL to
acpi_evaluate_integer(). Could this trigger an invalid evaluation of the
ACPI root namespace?
Finally, since MAX_FANS is 3, if this function is called for channel 2,
could checking cfg->paths[channel + 1] and data->active_handles[channel + 1]
read index 3, resulting in an out-of-bounds array access?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260417142455.18806-1-sergiomelas@gmail.com?part=1
next prev parent reply other threads:[~2026-04-17 15:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 14:24 [PATCH v2 1/2] hwmon: (yogafan) Use u32 types and improve RLLag filter Sergio Melas
2026-04-17 14:24 ` [PATCH v2 2/2] hwmon: (yogafan) Add support for new Yoga, Legion and LOQ models Sergio Melas
2026-04-17 16:31 ` sashiko-bot
2026-04-17 15:07 ` sashiko-bot [this message]
2026-04-28 10:44 ` [PATCH v2 1/2] hwmon: (yogafan) Use u32 types and improve RLLag filter Ilpo Järvinen
2026-04-28 17:13 ` 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=20260417150711.0CCE2C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=sergiomelas@gmail.com \
/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.