From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: wsa+renesas@sang-engineering.com, robh@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 05/11] ASoC: renesas: fsi: Fix register access from in-flight IRQ after shutdown
Date: Tue, 09 Jun 2026 11:59:07 +0000 [thread overview]
Message-ID: <20260609115908.189B71F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260609113836.45079-6-phucduc.bui@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The newly added `fsi_stream_is_working()` checks introduce a Time-of-Check to Time-of-Use (TOCTOU) race condition with the clock disablement path.
Pre-existing issues:
- [High] The patch fails to prevent system hangs during in-flight IRQs because it misses the `fsi_stream_transfer()` path, which still performs unprotected hardware accesses and NULL pointer dereferences.
--
commit 6fe54dc43154d802e5ce8471d592fd6f73f622bd
Author: bui duc phuc <phucduc.bui@gmail.com>
ASoC: renesas: fsi: Fix register access from in-flight IRQ after shutdown
This commit attempts to fix system hangs caused by in-flight IRQs accessing
registers when the SPU clock is disabled. It introduces fsi_stream_is_working()
checks in fsi_count_fifo_err() and fsi_irq_clear_status() to abort early if no
streams are active.
> diff --git a/sound/soc/renesas/fsi.c b/sound/soc/renesas/fsi.c
> index 0bd0e0c8c5a30..3e3c6fd7c56b8 100644
> --- a/sound/soc/renesas/fsi.c
> +++ b/sound/soc/renesas/fsi.c
> @@ -470,6 +470,10 @@ static int fsi_get_current_fifo_samples(struct fsi_priv *fsi,
>
> static void fsi_count_fifo_err(struct fsi_priv *fsi)
> {
> + if (!fsi_stream_is_working(fsi, &fsi->playback) &&
> + !fsi_stream_is_working(fsi, &fsi->capture))
> + return;
> +
[Severity: High]
Does this introduce a time-of-check to time-of-use race condition?
The fsi_stream_is_working() function acquires master->lock, checks the
substream, and immediately drops the lock. Because the lock is released before
the hardware access below:
u32 ostatus = fsi_reg_read(fsi, DOFF_ST);
u32 istatus = fsi_reg_read(fsi, DIFF_ST);
Could a concurrent ALSA shutdown sequence on another CPU execute
fsi_stream_quit() and fsi_hw_shutdown() to disable the SPU clock exactly in
this window, leading to the same system hang?
[ ... ]
> @@ -681,6 +685,10 @@ static void fsi_irq_clear_status(struct fsi_priv *fsi)
> u32 data = 0;
> struct fsi_master *master = fsi_get_master(fsi);
>
> + if (!fsi_stream_is_working(fsi, &fsi->playback) &&
> + !fsi_stream_is_working(fsi, &fsi->capture))
> + return;
> +
> data |= AB_IO(1, fsi_get_port_shift(fsi, &fsi->playback));
> data |= AB_IO(1, fsi_get_port_shift(fsi, &fsi->capture));
>
[Severity: High]
This isn't a bug introduced by this patch, but does the in-flight IRQ still
trigger hardware accesses and NULL pointer dereferences through other paths?
If fsi_interrupt() runs during shutdown, it calls fsi_stream_transfer()
unconditionally without checking fsi_stream_is_working() first:
sound/soc/renesas/fsi.c:fsi_interrupt() {
if (int_st & AB_IO(1, AO_SHIFT))
fsi_stream_transfer(&master->fsia.playback);
...
}
In PIO mode, this leads to fsi_pio_push() which reads the hardware registers
before verifying the stream state:
sample_space = io->fifo_sample_capa -
fsi_get_current_fifo_samples(fsi, io);
In DMA mode, it leads to fsi_dma_transfer() which dereferences io->substream
directly:
struct snd_soc_dai *dai = fsi_get_dai(io->substream);
struct snd_pcm_substream *substream = io->substream;
Can this still cause a system hang or a NULL pointer dereference if the
stream clock is already disabled and io->substream is set to NULL?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609113836.45079-1-phucduc.bui@gmail.com?part=5
next prev parent reply other threads:[~2026-06-09 11:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 11:38 [PATCH v6 00/11] ASoC: renesas: fsi: Fix system hang by adding SPU clock phucduc.bui
2026-06-09 11:38 ` [PATCH v6 01/11] ASoC: dt-bindings: renesas,fsi: add support multiple clocks phucduc.bui
2026-06-09 11:50 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 02/11] ARM: dts: renesas: r8a7740: Add clocks for FSI phucduc.bui
2026-06-09 11:38 ` [PATCH v6 03/11] ASoC: renesas: fsi: Fix trigger stop ordering phucduc.bui
2026-06-09 12:01 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 04/11] ASoC: renesas: fsi: Move fsi_stream_is_working() phucduc.bui
2026-06-09 11:51 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 05/11] ASoC: renesas: fsi: Fix register access from in-flight IRQ after shutdown phucduc.bui
2026-06-09 11:59 ` sashiko-bot [this message]
2026-06-09 11:38 ` [PATCH v6 06/11] ASoC: renesas: fsi: Move fsi_clk_init() phucduc.bui
2026-06-09 11:55 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 07/11] ASoC: renesas: fsi: Use devm_clk_get_optional() for optional clocks phucduc.bui
2026-06-09 11:56 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 08/11] ASoC: renesas: fsi: refactor clock initialization phucduc.bui
2026-06-09 12:06 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 09/11] ASoC: renesas: fsi: Add SPU clock support phucduc.bui
2026-06-09 11:38 ` [PATCH v6 10/11] ASoC: renesas: fsi: add fsi_clk_prepare/unprepare() phucduc.bui
2026-06-09 12:08 ` sashiko-bot
2026-06-09 11:38 ` [PATCH v6 11/11] ASoC: renesas: fsi: Add SPU clock control in hw_startup/shutdown phucduc.bui
2026-06-09 12:10 ` 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=20260609115908.189B71F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=phucduc.bui@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.com \
/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