From: sashiko-bot@kernel.org
To: "Kaitao Cheng" <kaitao.cheng@linux.dev>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 09/14] spi: stm32-qspi: Open-code message transfer walk
Date: Tue, 09 Jun 2026 06:55:26 +0000 [thread overview]
Message-ID: <20260609065527.A4B861F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260609062526.94907-7-kaitao.cheng@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Early returns in `stm32_qspi_transfer_one_message` fail to call `spi_finalize_current_message()`, leaking the SPI message and hanging the caller.
- [High] The driver mishandles SPI transfers where both `tx_buf` and `rx_buf` are NULL but `len > 0`, causing a NULL pointer dereference.
--
commit 0feb4c5cf513d6c2af724ffe0a636c0f0b92a880
Author: Kaitao Cheng <chengkaitao@kylinos.cn>
spi: stm32-qspi: Open-code message transfer walk
A later change will make list_for_each_entry() cache the next element
before entering the loop body. stm32_qspi_transfer_one_message() can
consume the following transfer as part of the current operation and then
advance the loop cursor to that entry.
Keep the transfer walk open-coded so the loop step observes that cursor
update and skips the consumed transfer. This preserves the existing
message sequencing semantics and prepares the code for the list iterator
update.
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index ea69fe25686f3..e264fee2bd2d7 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
> @@ -576,7 +576,10 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
>
> gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true);
>
> - list_for_each_entry(transfer, &msg->transfers, transfer_list) {
> + for (transfer = list_first_entry(&msg->transfers,
> + typeof(*transfer), transfer_list);
> + !list_entry_is_head(transfer, &msg->transfers, transfer_list);
> + transfer = list_next_entry(transfer, transfer_list)) {
> u8 dummy_bytes = 0;
>
> memset(&op, 0, sizeof(op));
[Severity: High]
This is a pre-existing issue, but I noticed early returns in
stm32_qspi_transfer_one_message() might fail to call
spi_finalize_current_message() and leak the SPI message:
if (!spi_get_csgpiod(spi, 0))
return -EOPNOTSUPP;
ret = pm_runtime_resume_and_get(qspi->dev);
if (ret < 0)
return ret;
Could these early returns cause spi_sync() to hang indefinitely on
wait_for_completion() and permanently lock the SPI bus? Should we arrange for
spi_finalize_current_message() to be called in these error paths?
[Severity: High]
This isn't a bug introduced by this patch, but there might be an issue with
how the driver handles SPI transfers where both tx_buf and rx_buf are NULL
but len > 0. In stm32_qspi_transfer_one_message():
} else {
qspi->fmode = CCR_FMODE_INDW;
op.data.buswidth = transfer->tx_nbits;
op.data.dir = SPI_MEM_DATA_OUT;
op.data.buf.out = transfer->tx_buf;
}
If a local user sends a message via spidev with tx_buf = 0, rx_buf = 0, and
len > 0, the driver assumes it is a transmit operation and assigns
op.data.buf.out to NULL.
Does the operation then fall back to stm32_qspi_tx_poll() which loops over
len, and since the transmit FIFO is empty, immediately satisfies the FIFO
Threshold Flag?
If so, could this result in dereferencing the NULL buf pointer in
stm32_qspi_tx_poll():
fifo(buf, qspi->io_base + QSPI_DR, step);
len -= step;
buf += step;
and triggering a kernel panic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609064122.95825-1-kaitao.cheng@linux.dev?part=9
next prev parent reply other threads:[~2026-06-09 6:55 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 6:13 [PATCH v2 00/14] list: Prepare entry iterators to cache cursor state Kaitao Cheng
2026-06-09 6:13 ` [PATCH v2 01/14] drbd: Open-code transfer log list walk Kaitao Cheng
2026-06-09 6:53 ` sashiko-bot
2026-06-09 6:13 ` [PATCH v2 02/14] firewire: core: Open-code topology " Kaitao Cheng
2026-06-09 6:53 ` sashiko-bot
2026-06-09 6:25 ` [PATCH v2 03/14] drm/bridge: Open-code bridge chain list walks Kaitao Cheng
2026-06-09 6:25 ` [PATCH v2 04/14] drm/i915/gt: Open-code active timeline walk Kaitao Cheng
2026-06-09 7:00 ` Andy Shevchenko
2026-06-09 6:25 ` [PATCH v2 05/14] drm/i915: Open-code DFS dependency list walk Kaitao Cheng
2026-06-09 6:25 ` [PATCH v2 06/14] drm/ttm: Open-code reservation " Kaitao Cheng
2026-06-09 6:51 ` sashiko-bot
2026-06-09 6:25 ` [PATCH v2 07/14] spi: fsi: Open-code message transfer walk Kaitao Cheng
2026-06-09 7:02 ` Andy Shevchenko
2026-06-09 6:25 ` [PATCH v2 08/14] spi: stm32-ospi: " Kaitao Cheng
2026-06-09 6:57 ` sashiko-bot
2026-06-09 6:25 ` [PATCH v2 09/14] spi: stm32-qspi: " Kaitao Cheng
2026-06-09 6:55 ` sashiko-bot [this message]
2026-06-09 6:38 ` [PATCH v2 10/14] spi: tegra210-quad: " Kaitao Cheng
2026-06-09 6:38 ` [PATCH v2 11/14] locking/locktorture: Open-code ww mutex list walk Kaitao Cheng
2026-06-09 6:54 ` sashiko-bot
2026-06-09 6:38 ` [PATCH v2 12/14] locking/ww_mutex: Open-code stress reorder " Kaitao Cheng
2026-06-09 6:57 ` [PATCH v2 10/14] spi: tegra210-quad: Open-code message transfer walk sashiko-bot
2026-06-09 6:41 ` [PATCH v2 13/14] ASoC: dapm: Open-code widget invalidation walk Kaitao Cheng
2026-06-09 6:41 ` [PATCH v2 14/14] list: Cache cursors in entry iterators Kaitao Cheng
2026-06-09 6:59 ` sashiko-bot
2026-06-09 6:55 ` [PATCH v2 13/14] ASoC: dapm: Open-code widget invalidation walk sashiko-bot
2026-06-09 6:47 ` [PATCH v2 00/14] list: Prepare entry iterators to cache cursor state Andy Shevchenko
2026-06-09 7:05 ` Andy Shevchenko
2026-06-09 10:33 ` Christian König
2026-06-10 6:14 ` Kaitao Cheng
2026-06-10 8:07 ` Christian König
2026-06-10 8:18 ` Kaitao Cheng
2026-06-10 9:11 ` Christian König
2026-06-10 15:02 ` Andy Shevchenko
2026-06-11 8:01 ` Christian König
2026-06-11 8:29 ` Andy Shevchenko
2026-06-11 8:39 ` Christian König
2026-06-11 18:31 ` Andy Shevchenko
2026-06-11 12:27 ` Kaitao Cheng
2026-06-10 14:43 ` Andy Shevchenko
2026-06-11 4:42 ` Kaitao Cheng
2026-06-11 6:54 ` Andy Shevchenko
2026-06-11 7:36 ` Kaitao Cheng
2026-06-11 7:52 ` Andy Shevchenko
2026-06-11 12:04 ` Kaitao Cheng
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=20260609065527.A4B861F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kaitao.cheng@linux.dev \
--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