From: sashiko-bot@kernel.org
To: "Antoni Pokusinski" <apokusinski01@gmail.com>
Cc: robh@kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
conor+dt@kernel.org, linux-rtc@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v3 4/8] rtc: abx80x: add irq to struct abx80x_priv
Date: Fri, 31 Jul 2026 19:04:49 +0000 [thread overview]
Message-ID: <20260731190450.548A81F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260731184831.44037-5-apokusinski01@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Read-modify-write of the status register introduces a race condition that loses interrupts.
- [High] Unconditional failure in `abx80x_read_alarm` due to incorrect handling of `i2c_smbus_read_i2c_block_data` return value.
--
--- Patch [4]: [PATCH v3 4/8] rtc: abx80x: add irq to struct abx80x_priv ---
commit be354d8ef94de08e1314876fad55888243ca019f
Author: Antoni Pokusinski <apokusinski01@gmail.com>
rtc: abx80x: add irq to struct abx80x_priv
This adds the irq field to struct abx80x_priv so the interrupt number is not
strictly tied to the i2c_client structure. This allows it to be more easily
accessed for ABX81X SPI clocks.
> diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
> --- a/drivers/rtc/rtc-abx80x.c
> +++ b/drivers/rtc/rtc-abx80x.c
> @@ -299,11 +300,12 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
[Severity: High]
This is a pre-existing issue, but I noticed a potential race condition with
the status register.
In abx80x_handle_irq(), there is a read-modify-write sequence:
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
...
i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS,
status & ~(ABX8XX_STATUS_AF | ABX8XX_STATUS_WDT));
If a hardware interrupt (such as an RTC alarm or watchdog) sets a new flag
in ABX8XX_REG_STATUS exactly between the read and write calls, wouldn't the
write operation write back a 0 for the newly set bit and inadvertently clear
it without handling it?
This same pattern appears to be present in abx80x_ioctl() as well:
tmp = i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS,
status);
Could this cause hardware interrupts or status flags to be silently dropped?
> static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t)
> {
> struct i2c_client *client = to_i2c_client(dev);
> + struct abx80x_priv *priv = i2c_get_clientdata(client);
> unsigned char buf[7];
>
> int irq_mask, err;
>
> - if (client->irq <= 0)
> + if (priv->irq <= 0)
> return -EINVAL;
>
> err = i2c_smbus_read_i2c_block_data(client, ABX8XX_REG_ASC,
[Severity: High]
This isn't a bug introduced by this patch, but does this error check work
as intended?
i2c_smbus_read_i2c_block_data() returns the number of bytes read (which
would be 7) on success.
Looking at the code just below this in abx80x_read_alarm():
err = i2c_smbus_read_i2c_block_data(client, ABX8XX_REG_ASC,
sizeof(buf), buf);
if (err)
return err;
Wouldn't this evaluate to true on a successful read, causing the function
to prematurely abort and pass the byte count back as an error code?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260731184831.44037-1-apokusinski01@gmail.com?part=4
next prev parent reply other threads:[~2026-07-31 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 18:48 [PATCH v3 0/8] rtc: abx80x: add support for abx81x Antoni Pokusinski
2026-07-31 18:48 ` [PATCH v3 1/8] dt-bindings: rtc: abx80x: document ABX81X RTCs Antoni Pokusinski
2026-07-31 18:57 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 2/8] rtc: abx80x: add mutex protection for register writes Antoni Pokusinski
2026-07-31 19:02 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 3/8] rtc: abx80x: properly handle shared IRQs Antoni Pokusinski
2026-07-31 19:05 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 4/8] rtc: abx80x: add irq to struct abx80x_priv Antoni Pokusinski
2026-07-31 19:04 ` sashiko-bot [this message]
2026-07-31 18:48 ` [PATCH v3 5/8] rtc: abx80x: use regmap instead of I2C specific API Antoni Pokusinski
2026-07-31 19:05 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 6/8] rtc: abx80x: replace read-modify-write pattern with regmap helpers Antoni Pokusinski
2026-07-31 19:01 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 7/8] rtc: abx80x: create abx80x_i2c_probe() Antoni Pokusinski
2026-07-31 19:02 ` sashiko-bot
2026-07-31 18:48 ` [PATCH v3 8/8] rtc: abx80x: add support for ABX81X Antoni Pokusinski
2026-07-31 19:05 ` 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=20260731190450.548A81F00AC4@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.