From: sashiko-bot@kernel.org
To: "Paul Cercueil" <paul.cercueil@bootlin.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 3/4] spi: cadence-xspi: Add support for panic writes
Date: Wed, 02 Dec 2026 13:31:23 +0000 [thread overview]
Message-ID: <sashiko-outbox-245881@kernel.org> (raw)
In-Reply-To: <20261202132135.470814-4-paul.cercueil@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] spi: cadence-xspi: sdma_size bounds check bypassed in
cdns_xspi_sdma_handle()
--
commit 111b594c701d92659414802088644363c5b37dd0
Author: Tanmay Jagdale <tanmay@marvell.com>
spi: cadence-xspi: Add support for panic writes
This commit advertises panic write support for the Cadence XSPI controller
and updates the STIG and SDMA paths to avoid sleeping, interrupts, and DMA
when op->panic_write is set.
> diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
> index 4a5376e495c6a..55886eb5f34ac 100644
> --- a/drivers/spi/spi-cadence-xspi.c
> +++ b/drivers/spi/spi-cadence-xspi.c
[ ... ]
> @@ -641,7 +643,7 @@ static inline void cdns_xspi_sdma_write(struct cdns_xspi_dev *cdns_xspi, size_t
> iowrite8_rep(dst, (const u8 *)buf + offset, len);
> }
>
> -static int cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi)
> +static int cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi, bool use_dma)
> {
> u32 sdma_size, sdma_trd_info;
> u8 sdma_dir;
> @@ -651,16 +653,18 @@ static int cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi)
> sdma_trd_info = readl(cdns_xspi->iobase + CDNS_XSPI_SDMA_TRD_INFO_REG);
> sdma_dir = FIELD_GET(CDNS_XSPI_SDMA_DIR, sdma_trd_info);
>
> - if (sdma_size > cdns_xspi->sdma_xfer_len) {
> - dev_err(cdns_xspi->dev,
> - "SDMA size %u exceeds the requested length %u\n",
> - sdma_size, cdns_xspi->sdma_xfer_len);
> - return -EINVAL;
> + if (use_dma) {
> + if (sdma_size > cdns_xspi->sdma_xfer_len) {
> + dev_err(cdns_xspi->dev,
> + "SDMA size %u exceeds the requested length %u\n",
> + sdma_size, cdns_xspi->sdma_xfer_len);
> + return -EINVAL;
> + }
> + ret = cdns_xspi_dma_transfer(cdns_xspi, sdma_size,
> + sdma_dir == CDNS_XSPI_SDMA_DIR_READ);
> + if (ret != -EAGAIN)
> + return ret;
> }
> - ret = cdns_xspi_dma_transfer(cdns_xspi, sdma_size,
> - sdma_dir == CDNS_XSPI_SDMA_DIR_READ);
> - if (ret != -EAGAIN)
> - return ret;
>
> switch (sdma_dir) {
> case CDNS_XSPI_SDMA_DIR_READ:
[Severity: Medium]
Should the sdma_size > cdns_xspi->sdma_xfer_len check remain outside the
if (use_dma) block?
When use_dma is false during a panic write, skipping this check passes an
unvalidated sdma_size from CDNS_XSPI_SDMA_SIZE_REG to cdns_xspi_sdma_read()
or cdns_xspi_sdma_write(), which can read or write past the end of
cdns_xspi->in_buffer or cdns_xspi->out_buffer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202132135.470814-1-paul.cercueil@bootlin.com?part=3
next prev parent reply other threads:[~2026-12-02 13:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:21 [PATCH v5 0/4] spi: cadence-xspi: Add support for panic mem writes Paul Cercueil
2026-12-02 13:21 ` [PATCH v5 1/4] spi: cadence-xspi: Handle SDMA errors in cdns_xspi_is_sdma_ready() Paul Cercueil
2026-12-02 13:27 ` sashiko-bot
2026-12-02 13:21 ` [PATCH v5 2/4] spi: cadence-xspi: Add irq-less support Paul Cercueil
2026-12-02 13:33 ` sashiko-bot
2026-12-02 13:21 ` [PATCH v5 3/4] spi: cadence-xspi: Add support for panic writes Paul Cercueil
2026-12-02 13:31 ` sashiko-bot [this message]
2026-12-02 13:21 ` [PATCH v5 4/4] spi: dt-bindings: cadence: Make XSPI's IRQ line optional Paul Cercueil
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=sashiko-outbox-245881@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=paul.cercueil@bootlin.com \
--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.