From: sashiko-bot@kernel.org
To: "Johan Dahlin" <jdahlin@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 3/5] hwmon: (nct6683) Add pwm[1-8]_enable
Date: Tue, 25 Aug 2026 09:44:00 +0000 [thread overview]
Message-ID: <20260825094401.0E4391F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825092546.669450-4-jdahlin@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The sysfs callbacks `show_pwm_enable()` and `store_pwm_enable()` incorrectly cast their attribute argument to `struct sensor_device_attribute_2 *`, leading to type confusion with `struct sensor_device_attribute` and causing failures on Big-Endian architectures.
--
--- Patch [3]: [PATCH 3/5] hwmon: (nct6683) Add pwm[1-8]_enable ---
commit ae1360636538f417a87b23c1e1c204ef9329c018
Author: Johan Dahlin <jdahlin@gmail.com>
hwmon: (nct6683) Add pwm[1-8]_enable
This commit exposes the manual-control bitmap as pwm[1-8]_enable for fan
control on supported boards, falling back to read-only hardware control
on unsupported variants.
Link: https://github.com/Fred78290/nct6687d
Link: https://github.com/LibreHardwareMonitor/LibreHardwareMonitor
> diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
> index b43e915f9d0fb..0324ace707a53 100644
> --- a/drivers/hwmon/nct6683.c
> +++ b/drivers/hwmon/nct6683.c
[ ... ]
> @@ -962,25 +963,93 @@ store_pwm(struct device *dev, struct device_attribute *attr, const char *buf,
[ ... ]
> +static ssize_t
> +show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
[Severity: Medium]
Does this cast cause type confusion with struct sensor_device_attribute?
The template initializes the attribute as a struct sensor_device_attribute,
which uses an int for the index field, but it is cast here to a struct
sensor_device_attribute_2, which uses a u8 for the index.
On Big-Endian architectures, reading a u8 from an int field aliases the MSB.
Would this result in an index of 0, effectively mapping all manual fan
control operations to channel 0 and breaking functionality for fans 1-7?
> + struct nct6683_data *data = dev_get_drvdata(dev);
> + u8 mode;
> +
> + mutex_lock(&data->update_lock);
> + mode = nct6683_read(data, NCT6683_REG_FAN_CTRL_MODE);
> + mutex_unlock(&data->update_lock);
> +
> + return sysfs_emit(buf, "%d\n", (mode & BIT(sattr->index)) ? 1 : 2);
> +}
> +
> +static ssize_t
> +store_pwm_enable(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
[Severity: Medium]
Is there a similar type confusion issue on the store path?
Casting to struct sensor_device_attribute_2 and reading the u8 index might
similarly fail on Big-Endian systems during store operations, causing writes
to unintended channels.
> + struct nct6683_data *data = dev_get_drvdata(dev);
> + u8 bit = BIT(sattr->index);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825092546.669450-1-jdahlin@gmail.com?part=3
next prev parent reply other threads:[~2026-08-25 9:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:25 [PATCH 0/5] hwmon: (nct6683) Fan control for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25 9:25 ` [PATCH 1/5] hwmon: (nct6683) Retry pwm writes until they take effect Johan Dahlin
2026-08-25 9:34 ` sashiko-bot
2026-08-25 9:25 ` [PATCH 2/5] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25 9:28 ` sashiko-bot
2026-08-25 9:25 ` [PATCH 3/5] hwmon: (nct6683) Add pwm[1-8]_enable Johan Dahlin
2026-08-25 9:44 ` sashiko-bot [this message]
2026-08-28 16:17 ` Guenter Roeck
2026-08-25 9:25 ` [PATCH 4/5] hwmon: (nct6683) Restore fan control mode on driver removal Johan Dahlin
2026-08-25 9:33 ` sashiko-bot
2026-08-25 9:25 ` [PATCH 5/5] hwmon: (nct6683) Enable pwm control on ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25 9:38 ` sashiko-bot
2026-09-17 17:35 ` Fabio Baltieri
2026-09-17 20:03 ` 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=20260825094401.0E4391F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jdahlin@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--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.