From: sashiko-bot@kernel.org
To: "Jan-Henrik Bruhn" <kernel@jhbruhn.de>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3] hwmon: (lm63) expose PWM frequency and LUT hysteresis as writable
Date: Sat, 23 May 2026 10:58:37 +0000 [thread overview]
Message-ID: <20260523105837.67B9C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260523095412.3341202-1-kernel@jhbruhn.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing lock in `pwm1_freq_show` causes a data race and a potential divide-by-zero kernel panic.
--
commit 1bf46f1b90af417821722eaed56484734ef9e3ae
Author: Jan-Henrik Bruhn <kernel@jhbruhn.de>
hwmon: (lm63) expose PWM frequency and LUT hysteresis as writable
This commit exposes the PWM frequency and LUT hysteresis as writable
sysfs attributes. It adds a pwm1_freq attribute to select the closest
SCS + PFR combination, and exposes a chip-wide pwm1_auto_point_temp_hyst
attribute for the hysteresis amount.
> diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
> index 30500b4d22212..90c49c448c624 100644
> --- a/drivers/hwmon/lm63.c
> +++ b/drivers/hwmon/lm63.c
[ ... ]
> @@ -455,6 +458,86 @@ static ssize_t pwm1_enable_store(struct device *dev,
> return count;
> }
>
> +static ssize_t pwm1_freq_show(struct device *dev,
> + struct device_attribute *dummy, char *buf)
> +{
> + struct lm63_data *data = lm63_update_device(dev);
> + unsigned int base = (data->config_fan & 0x08) ?
> + LM63_PWM_BASE_SLOW_HZ : LM63_PWM_BASE_FAST_HZ;
> +
> + return sprintf(buf, "%u\n", base / data->pwm1_freq);
[Severity: High]
Can this read of data->pwm1_freq race with an update, resulting in a
divide-by-zero exception?
Looking at lm63_update_device(), it acquires data->update_lock and can
temporarily set data->pwm1_freq to 0 before clamping it to 1:
lm63_update_device() {
mutex_lock(&data->update_lock);
...
data->pwm1_freq = i2c_smbus_read_byte_data(client, LM63_REG_PWM_FREQ);
if (data->pwm1_freq == 0)
data->pwm1_freq = 1;
...
}
Since pwm1_freq_show() does not hold data->update_lock, could it read
data->pwm1_freq during this transient 0 state and cause a kernel panic?
> +}
> +
[ ... ]
> @@ -629,6 +712,42 @@ static ssize_t show_lut_temp_hyst(struct device *dev,
> return sprintf(buf, "%d\n", temp);
> }
>
> +/*
> + * The LM63 has a single hysteresis register shared by all LUT entries.
> + * Expose it as a chip-wide hysteresis amount in millidegrees; the
> + * per-point pwm1_auto_pointN_temp_hyst attributes remain read-only and
> + * show the resulting absolute trip-down temperature for each entry.
> + */
> +static ssize_t pwm1_auto_point_temp_hyst_show(struct device *dev,
> + struct device_attribute *dummy,
> + char *buf)
> +{
> + struct lm63_data *data = lm63_update_device(dev);
> +
> + return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->lut_temp_hyst));
[Severity: High]
Does accessing data->lut_temp_hyst here without holding data->update_lock
also result in a data race with concurrent updates?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260523095412.3341202-1-kernel@jhbruhn.de?part=1
next prev parent reply other threads:[~2026-05-23 10:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 13:54 [PATCH] hwmon: (lm63) expose PWM frequency and LUT hysteresis as writable Jan-Henrik Bruhn
2026-05-22 14:28 ` sashiko-bot
2026-05-22 18:47 ` Jan-Henrik Bruhn
2026-05-22 19:34 ` Guenter Roeck
2026-05-22 19:55 ` Jan-Henrik Bruhn
2026-05-22 20:22 ` [PATCH v2] " Jan-Henrik Bruhn
2026-05-22 20:59 ` sashiko-bot
2026-05-23 9:53 ` Jan-Henrik Bruhn
2026-05-23 13:11 ` Guenter Roeck
2026-05-23 13:31 ` Jan-Henrik Bruhn
2026-05-23 9:54 ` [PATCH v3] " Jan-Henrik Bruhn
2026-05-23 10:58 ` sashiko-bot [this message]
2026-05-23 13:36 ` [PATCH v4] " Jan-Henrik Bruhn
2026-05-23 14:13 ` sashiko-bot
2026-05-24 15:26 ` 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=20260523105837.67B9C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kernel@jhbruhn.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox