From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain via B4 Relay"
<devnull+abdurrahman.nexthop.ai@kernel.org>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 4/7] hwmon: (pmbus/adm1266) add clear_blackbox debugfs entry
Date: Sat, 09 May 2026 01:10:13 +0000 [thread overview]
Message-ID: <20260509011013.E87FFC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508-adm1266-v1-4-ec08bf29e0ce@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing locking in the debugfs clear_blackbox attribute handler creates a race condition with nvmem blackbox reads and violates hwmon subsystem guidelines.
--
commit bc35a67bf6371f1a9ee8f0d0c2436676ca57954d
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
hwmon: (pmbus/adm1266) add clear_blackbox debugfs entry
This commit exposes a write-only debugfs file alongside sequencer_state to
clear the ADM1266 blackbox. Writing any data to this file issues a 2-byte
block-write command to the READ_BLACKBOX register.
> --- a/drivers/hwmon/pmbus/adm1266.c
> +++ b/drivers/hwmon/pmbus/adm1266.c
[ ... ]
> +static ssize_t adm1266_clear_blackbox_write(struct file *file, const char __user *ubuf,
> + size_t count, loff_t *ppos)
> +{
> + struct i2c_client *client = file->private_data;
> + u8 payload[2] = { 0xFE, 0x00 };
> + int ret;
> +
> + ret = i2c_smbus_write_block_data(client, ADM1266_READ_BLACKBOX,
> + sizeof(payload), payload);
Could this clear command race with concurrent reads of the blackbox?
Looking at adm1266_nvmem_read_blackbox(), it performs a multi-transaction
sequence where it first reads the record_count, then loops to read individual
records:
drivers/hwmon/pmbus/adm1266.c:adm1266_nvmem_read_blackbox() {
...
ret = i2c_smbus_read_block_data(data->client, ADM1266_BLACKBOX_INFO, buf);
...
record_count = buf[3];
for (index = 0; index < record_count; index++) {
ret = adm1266_pmbus_block_xfer(data, ADM1266_READ_BLACKBOX, 1,
&index, read_buff);
...
}
If this write runs concurrently, it seems it could clear the hardware
blackbox mid-read since the core I2C bus lock only serializes individual
transactions. This might cause the remaining nvmem reads to fetch corrupted
data or fail with I/O errors.
The hwmon subsystem guidelines also mention that drivers must implement
locking for attributes registered outside the core subsystem. Should this
write be protected to serialize it against other hardware accesses?
> + if (ret < 0)
> + return ret;
> +
> + return count;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-adm1266-v1-0-ec08bf29e0ce@nexthop.ai?part=4
next prev parent reply other threads:[~2026-05-09 1:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 23:33 [PATCH 0/7] hwmon: (pmbus/adm1266) RTC fix, blackbox, FW rev, rtc_class Abdurrahman Hussain via B4 Relay
2026-05-08 23:33 ` [PATCH 1/7] hwmon: (pmbus/adm1266) use wall-clock seconds for SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-08 23:48 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 2/7] hwmon: (pmbus/adm1266) write fractional-seconds field of SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-09 0:06 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 3/7] hwmon: (pmbus/adm1266) add firmware_revision debugfs entry Abdurrahman Hussain via B4 Relay
2026-05-09 0:38 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 4/7] hwmon: (pmbus/adm1266) add clear_blackbox " Abdurrahman Hussain via B4 Relay
2026-05-09 1:10 ` sashiko-bot [this message]
2026-05-08 23:33 ` [PATCH 5/7] hwmon: (pmbus/adm1266) add powerup_counter " Abdurrahman Hussain via B4 Relay
2026-05-09 1:48 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 6/7] hwmon: (pmbus/adm1266) register rtc_class device backed by SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-09 2:26 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 7/7] hwmon: (pmbus/adm1266) include adapter number in GPIO line label Abdurrahman Hussain via B4 Relay
2026-05-09 2:39 ` sashiko-bot
2026-05-09 14:14 ` [PATCH 0/7] hwmon: (pmbus/adm1266) RTC fix, blackbox, FW rev, rtc_class Guenter Roeck
2026-05-09 21:58 ` Abdurrahman Hussain
2026-05-09 23:49 ` Guenter Roeck
2026-05-11 3:46 ` Abdurrahman Hussain
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=20260509011013.E87FFC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+abdurrahman.nexthop.ai@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@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