From: sashiko-bot@kernel.org
To: "Guenter Roeck" <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 1/5] hwmon: (pmbus/core) Introduce pmbus_read_smbus_i2c_block_data()
Date: Mon, 03 Aug 2026 19:47:38 +0000 [thread overview]
Message-ID: <20260803194739.5C38A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260803193535.2286578-2-linux@roeck-us.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The hwmon device is exposed to userspace before the driver probe is fully complete, causing a race condition on I2C page state.
--
--- Patch [1]: [PATCH 1/5] hwmon: (pmbus/core) Introduce pmbus_read_smbus_i2c_block_data() ---
commit 80dbae6dc3a3ada2ae6512549c713faf3d025f76
Author: Guenter Roeck <linux@roeck-us.net>
hwmon: (pmbus/core) Introduce pmbus_read_smbus_i2c_block_data()
PMBus drivers need support for reading SMBus block data. Unfortunately,
not all i2C controllers support this command.
Implement pmbus_read_smbus_i2c_block_data() which first tries to use
i2c_smbus_read_block_data(). If not supported, try to emulate it by calling
i2c_smbus_read_i2c_block_data(). Export the new function for use in PMBus
drivers.
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index ba3e9e9fc8bcc..df2409c89a840 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
[ ... ]
[Severity: High]
This is a pre-existing issue, but I noticed a potential race condition
during probe in pmbus_do_probe().
When devm_hwmon_device_register_with_groups() is called, the hwmon device
is exposed to userspace immediately:
drivers/hwmon/pmbus/pmbus_core.c:pmbus_do_probe() {
...
data->hwmon_dev = devm_hwmon_device_register_with_groups(dev, name,
data, data->groups);
if (IS_ERR(data->hwmon_dev)) {
dev_err(dev, "Failed to register hwmon device\n");
return PTR_ERR(data->hwmon_dev);
}
ret = pmbus_regulator_register(data);
if (ret)
return ret;
ret = pmbus_irq_setup(client, data);
if (ret)
return ret;
pmbus_init_debugfs(client, data);
...
}
Userspace (like udev) can immediately issue sysfs reads or writes, which hold
pmbus_lock and call pmbus_set_page().
Concurrently, the probe function continues execution and calls
pmbus_irq_setup() and pmbus_init_debugfs().
Both of these functions execute unlocked I2C operations that also call
pmbus_set_page(). Because pmbus_set_page() does not internally hold a lock,
the hardware I2C page state can become desynchronized from the software
data->currpage state.
Could this result in I2C operations being sent to the wrong page?
Since PMBus devices are often power supplies, if a sysfs write is directed to
the wrong page due to a race, could it change the voltage or limits on the
wrong power rail and potentially cause hardware damage?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803193535.2286578-1-linux@roeck-us.net?part=1
next prev parent reply other threads:[~2026-08-03 19:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 19:35 [PATCH 0/5] hwmon: (pmbus/core) Introduce and use pmbus_read_smbus_i2c_block_data() Guenter Roeck
2026-08-03 19:35 ` [PATCH 1/5] hwmon: (pmbus/core) Introduce pmbus_read_smbus_i2c_block_data() Guenter Roeck
2026-08-03 19:47 ` sashiko-bot [this message]
2026-08-04 8:45 ` Nuno Sá
2026-08-04 18:12 ` Guenter Roeck
2026-08-03 19:35 ` [PATCH 2/5] hwmon: (pmbus/adm1275) Use pmbus_read_smbus_i2c_block_data for block commands Guenter Roeck
2026-08-03 19:48 ` sashiko-bot
2026-08-03 19:35 ` [PATCH 3/5] hwmon: (pmbus/ltc2978) " Guenter Roeck
2026-08-03 19:50 ` sashiko-bot
2026-08-03 19:35 ` [PATCH 4/5] hwmon: (pmbus/max20830) " Guenter Roeck
2026-08-03 19:43 ` sashiko-bot
2026-08-03 19:35 ` [PATCH 5/5] hwmon: (pmbus/ir36021) " Guenter Roeck
2026-08-03 19:42 ` sashiko-bot
2026-08-04 8:50 ` [PATCH 0/5] hwmon: (pmbus/core) Introduce and use pmbus_read_smbus_i2c_block_data() 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=20260803194739.5C38A1F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox