All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guenter Roeck" <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 3/3] hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt
Date: Wed, 05 Aug 2026 01:08:37 +0000	[thread overview]
Message-ID: <20260805010838.4934C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805005721.1566034-4-linux@roeck-us.net>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] The `in_min_raw` cache for the inactive voltage monitoring channel is not initialized from the hardware EEPROM at boot, leading to the hardware undervoltage limit being clobbered with 0 when the channel is enabled.
- [High] Uninitialized stack variable `struct clk_init_data init` is passed to the Common Clock Framework, leading to undefined behavior and potential panics.
--

--- Patch [3]: [PATCH 3/3] hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt ---
commit b52e0acebe8052dfb365a719ef77509a10b27e3a
Author: Guenter Roeck <linux@roeck-us.net>

hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt

ltc4282_parse_dt() evaluates the wrong variable when parsing the current
limit.

> diff --git a/drivers/hwmon/ltc4282.c b/drivers/hwmon/ltc4282.c
> index bb1bcb3690163..b1675dc5b3c7f 100644
> --- a/drivers/hwmon/ltc4282.c
> +++ b/drivers/hwmon/ltc4282.c
> @@ -1394,7 +1394,7 @@ static int ltc4282_setup(struct ltc4282_state *st, struct device *dev)
>  	if (!ret) {
>  		int reg_val;
>  
> -		switch (val) {
> +		switch (st->vsense_max) {
>  		case 12500:
>  			reg_val = 0;
>  			break;

[Severity: High]
This isn't a bug introduced by this patch, but the in_min_raw cache for the
inactive voltage monitoring channel does not appear to be initialized from
hardware defaults during boot:

drivers/hwmon/ltc4282.c:ltc4282_get_defaults() {
...
	if (!st->in0_1_cache[LTC4282_CHAN_VSOURCE].en) {
		st->in0_1_cache[LTC4282_CHAN_VDD].en = true;
		return regmap_read(st->map, LTC4282_VSOURCE_MAX,
				   &st->in0_1_cache[LTC4282_CHAN_VSOURCE].in_max_raw);
	}

	return regmap_read(st->map, LTC4282_VSOURCE_MAX,
			   &st->in0_1_cache[LTC4282_CHAN_VDD].in_max_raw);
}

If a user later enables this inactive channel via sysfs, ltc4282_cache_sync()
writes the uninitialized in_min_raw (0) back to the hardware register:

drivers/hwmon/ltc4282.c:ltc4282_cache_sync() {
...
	ret = regmap_write(st->map, LTC4282_VSOURCE_MIN,
			   st->in0_1_cache[channel].in_min_raw);
...
}

Does this silently clobber and disable the hardware undervoltage limit?


[Severity: High]
This is a pre-existing issue, but I also noticed a potential problem with
uninitialized stack variables passed to the common clock framework:

drivers/hwmon/ltc4282.c:ltc428_clk_provider_setup() {
	struct clk_init_data init;
	int ret;

	if (!IS_ENABLED(CONFIG_COMMON_CLK))
		return 0;

	init.name =  devm_kasprintf(dev, GFP_KERNEL, "%s-clk",
				    fwnode_get_name(dev_fwnode(dev)));
...
	init.ops = &ltc4282_ops;
...
}

Since init is not zero-initialized, fields like init.num_parents and
init.parent_names will contain stack garbage. When devm_clk_hw_register()
evaluates init.num_parents, could it attempt to dereference the uninitialized
init.parent_names pointer and cause a panic during driver probe?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805005721.1566034-1-linux@roeck-us.net?part=3

  reply	other threads:[~2026-08-05  1:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  0:57 [PATCH 0/3] hwmon: (ltc4282) Fix issues reported by Sashiko Guenter Roeck
2026-08-05  0:57 ` [PATCH 1/3] hwmon: (ltc4282) Avoid overflow in maximum power calculation Guenter Roeck
2026-08-05  1:07   ` sashiko-bot
2026-08-05  0:57 ` [PATCH 2/3] hwmon: (ltc4282) Clamp negative current limits Guenter Roeck
2026-08-05  1:04   ` sashiko-bot
2026-08-05  9:22   ` Nuno Sá
2026-08-05 15:41     ` Guenter Roeck
2026-08-05 16:14       ` Nuno Sá
2026-08-05 17:19         ` Guenter Roeck
2026-08-05  0:57 ` [PATCH 3/3] hwmon: (ltc4282) Fix parsing adi,current-limit-sense-microvolt Guenter Roeck
2026-08-05  1:08   ` sashiko-bot [this message]
2026-08-05  9:26 ` [PATCH 0/3] hwmon: (ltc4282) Fix issues reported by Sashiko Nuno Sá
2026-08-05 14:28   ` Guenter Roeck
2026-08-05 16:15     ` Nuno Sá

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=20260805010838.4934C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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.