Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jan-Henrik Bruhn" <kernel@jhbruhn.de>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (lm63) expose PWM frequency and LUT hysteresis as writable
Date: Fri, 22 May 2026 14:28:50 +0000	[thread overview]
Message-ID: <20260522142850.E67A01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522135421.2951534-1-kernel@jhbruhn.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver fails to check if `i2c_smbus_read_byte_data()` returns a negative error code before assigning the result to an unsigned 8-bit variable, leading to hardware register corruption on I2C failure.
--

commit 280d2e57aec56ef87aeac8e747586012f93f520e
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 attributes
for the LM63 hardware monitoring driver. It adds pwm1_freq and a single
chip-wide pwm1_auto_point_temp_hyst attribute to configure the fan control.

> diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
> index 30500b4d22212..3c9e65e3d81db 100644
> --- a/drivers/hwmon/lm63.c
> +++ b/drivers/hwmon/lm63.c
[ ... ]
> @@ -455,6 +458,75 @@ static ssize_t pwm1_enable_store(struct device *dev,
>  	return count;
>  }
>  
[ ... ]
> +static ssize_t pwm1_freq_store(struct device *dev,
> +			       struct device_attribute *dummy,
> +			       const char *buf, size_t count)
> +{
[ ... ]
> +	mutex_lock(&data->update_lock);
> +	data->config_fan = i2c_smbus_read_byte_data(client, LM63_REG_CONFIG_FAN);

[Severity: High]
Does this code handle I2C read failures correctly?

If i2c_smbus_read_byte_data() fails, it returns a negative error code.
Because data->config_fan is an 8-bit unsigned variable, this negative
error code is silently truncated into a large positive value.

This corrupted value is then modified and unconditionally written back to
LM63_REG_CONFIG_FAN below, which could clobber other configuration bits
in the register and potentially break hardware fan control.

> +	if (slow_clock)
> +		data->config_fan |= 0x08;
> +	else
> +		data->config_fan &= ~0x08;
> +	i2c_smbus_write_byte_data(client, LM63_REG_CONFIG_FAN, data->config_fan);
> +	i2c_smbus_write_byte_data(client, LM63_REG_PWM_FREQ, pfr);
> +	data->pwm1_freq = pfr;
> +
> +	if (data->kind == lm96163) {
> +		u8 enh = i2c_smbus_read_byte_data(client,
> +						  LM96163_REG_CONFIG_ENHANCED);

[Severity: High]
Can this read also fail and silently truncate a negative error code to an
8-bit unsigned variable?

> +		data->pwm_highres = !slow_clock && pfr == 8 && (enh & 0x10);
> +	}
> +	mutex_unlock(&data->update_lock);
> +	return count;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522135421.2951534-1-kernel@jhbruhn.de?part=1

  reply	other threads:[~2026-05-22 14:28 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 [this message]
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
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=20260522142850.E67A01F000E9@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