From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v8 2/6] spmi: apple: Validate FIFO state
Date: Fri, 28 Aug 2026 09:26:44 +0000 [thread overview]
Message-ID: <20260828092645.5288B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828-t603x-spmi-v8-2-708d4d12e0fd@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unsafe Data / Silenced Error: The driver returns success (0) when extra data is left in the RX FIFO, feeding potentially corrupted or stale data to the client.
--
commit bd81188aa73e785d093e758b80b16d3e34cda43c
Author: Alba Mendez <me@alba.sh>
spmi: apple: Validate FIFO state
Check for data before reading the body of a reply, and check for
end of data afterwards.
> diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
> index 376cf682c43e0..15721cb41d5c8 100644
> --- a/drivers/spmi/spmi-apple-controller.c
> +++ b/drivers/spmi/spmi-apple-controller.c
[ ... ]
> @@ -86,6 +101,11 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
> }
> }
>
> + if (!(readl(spmi->regs + SPMI_STATUS_REG) & SPMI_RX_FIFO_EMPTY)) {
> + dev_warn(&ctrl->dev, "FIFO has extra data\n");
> + spmi->prev_fail = true;
> + }
> +
> return 0;
> }
[Severity: High]
When extra data is detected in the RX FIFO, spmi_read_cmd() logs a warning
and marks spmi->prev_fail = true, but continues to return 0 (success).
Does returning success here risk feeding corrupted or out-of-sync data (such
as stale data left by the bootloader) back to the caller instead of returning
an error code like -EIO?
[ ... ]
> @@ -115,6 +140,11 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
> /* Discard */
> readl(spmi->regs + SPMI_RSP_REG);
>
> + if (!(readl(spmi->regs + SPMI_STATUS_REG) & SPMI_RX_FIFO_EMPTY)) {
> + dev_warn(&ctrl->dev, "FIFO has extra data\n");
> + spmi->prev_fail = true;
> + }
> +
> return 0;
> }
[Severity: High]
Similarly to spmi_read_cmd(), spmi_write_cmd() detects that the FIFO is out
of sync but returns 0.
Should this also return an error code like -EIO to properly signal the
synchronization failure to the caller?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828-t603x-spmi-v8-0-708d4d12e0fd@chaosmail.tech?part=2
next prev parent reply other threads:[~2026-08-28 9:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 8:58 [PATCH v8 0/6] spmi: apple: Additional commands and interrupt support Sasha Finkelstein
2026-08-28 8:58 ` [PATCH v8 1/6] dt-bindings: spmi: apple,spmi: Add t603x and t8122 Sasha Finkelstein
2026-08-28 16:30 ` Conor Dooley
2026-08-28 8:58 ` [PATCH v8 2/6] spmi: apple: Validate FIFO state Sasha Finkelstein
2026-08-28 9:26 ` sashiko-bot [this message]
2026-08-28 8:58 ` [PATCH v8 3/6] spmi: apple: check transaction status Sasha Finkelstein
2026-08-28 8:59 ` [PATCH v8 4/6] spmi: apple: Implement remaining commands Sasha Finkelstein
2026-08-28 9:48 ` sashiko-bot
2026-08-28 8:59 ` [PATCH v8 5/6] spmi: apple: lock around FIFOs Sasha Finkelstein
2026-08-28 8:59 ` [PATCH v8 6/6] spmi: apple: Add interrupt functionality Sasha Finkelstein
2026-08-28 10:08 ` 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=20260828092645.5288B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=k@chaosmail.tech \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox