From: sashiko-bot@kernel.org
To: "Antoni Pokusinski" <apokusinski01@gmail.com>
Cc: linux-rtc@vger.kernel.org, robh@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 3/9] rtc: abx80x: add mutex protection for register writes
Date: Mon, 07 Sep 2026 20:46:33 +0000 [thread overview]
Message-ID: <20260907204634.2A7C11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907203216.53192-4-apokusinski01@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete mutex protection allows concurrent I2C reads to break configuration key sequences.
--
commit c33d071aef97a2d9a731cf3e557a1cf0fbf7c50c
Author: Antoni Pokusinski <apokusinski01@gmail.com>
rtc: abx80x: add mutex protection for register writes
The ABX80X RTC driver performs multi-step register operations such as
NVMEM transfers or register writes preceded by a configuration key
write. Add a mutex to serialize all the register writes to protect
these sequences against race conditions.
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> index e4fd7b5d4b110..44de234efecf7 100644
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
[ ... ]
> @@ -445,6 +458,7 @@ static ssize_t oscillator_store(struct device *dev,
> const char *buf, size_t count)
> {
> struct i2c_client *client = to_i2c_client(dev->parent);
> + struct abx80x_priv *priv = i2c_get_clientdata(client);
> int retval, flags, rc_mode = 0;
>
> if (strncmp(buf, "rc", 2) == 0) {
> @@ -456,6 +470,8 @@ static ssize_t oscillator_store(struct device *dev,
> return -EINVAL;
> }
>
> + guard(mutex)(&priv->lock);
> +
[Severity: High]
This isn't a bug introduced by this patch, but since this commit aims to
protect configuration key sequences from race conditions, does this leave a
similar race open for concurrent I2C reads?
If Thread A executes a protected write sequence (like oscillator_store), and
Thread B executes an RTC read operation, can Thread B's I2C read interleave
and reset the configuration key?
For example, abx80x_rtc_read_time() does not take priv->lock while reading
the ABX8XX_REG_HTH registers.
Similarly, abx80x_is_rc_mode() (called from sysfs and read_time) performs an
unlocked read of the ABX8XX_REG_OSS register.
The ABX8XX chip specification dictates that any intervening I2C read resets
the configuration key. This would leave the register locked, causing Thread
A's subsequent protected register write to silently fail without returning
an error to userspace.
Should priv->lock be taken during these read paths as well to fully prevent
I2C interleaving from aborting configuration key writes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907203216.53192-1-apokusinski01@gmail.com?part=3
next prev parent reply other threads:[~2026-09-07 20:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 20:32 [PATCH v6 0/9] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-09-07 20:32 ` [PATCH v6 1/9] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-09-07 20:41 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 2/9] rtc: abx80x: fix error check after i2c_smbus_read in read_alarm() Antoni Pokusinski
2026-09-07 20:41 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 3/9] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-09-07 20:46 ` sashiko-bot [this message]
2026-09-09 18:01 ` Antoni Pokusinski
2026-09-07 20:32 ` [PATCH v6 4/9] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-09-07 20:46 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 5/9] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-09-07 20:49 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 6/9] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-09-07 20:47 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 7/9] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-09-07 20:46 ` sashiko-bot
2026-09-09 18:03 ` Antoni Pokusinski
2026-09-07 20:32 ` [PATCH v6 8/9] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-09-07 20:41 ` sashiko-bot
2026-09-07 20:32 ` [PATCH v6 9/9] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-09-07 20:52 ` sashiko-bot
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=20260907204634.2A7C11F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=apokusinski01@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=robh@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 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.