* [PATCH] ASoC: zl38060: use bounce-buffered spi_write_then_read in bus write
@ 2026-11-25 22:25 Elkin Cruz
0 siblings, 0 replies; only message in thread
From: Elkin Cruz @ 2026-11-25 22:25 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, linux-kernel, llvm, irogers, Elkin Cruz, stable
In zl38_bus_write(), the local stack buffer buf is passed directly to
spi_write(). Passing stack memory to SPI transfers violates DMA safety
requirements and risks memory corruption when the SPI master performs
DMA.
Switch to spi_write_then_read(), which safely bounce-buffers stack
transfers through DMA-safe heap memory, matching the pattern already
used in zl38_bus_read().
Fixes: 52e8a94baf90 ("ASoC: Add initial ZL38060 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
I am trying out new Clang static analysis checks for kernel bug
classes, and they flagged this code as possibly buggy. The findings
were triaged/fixed and commit descriptions were drafted with help of AI,
then checked against linux-next (not runtime-tested on hardware).
Thanks,
Elkin
sound/soc/codecs/zl38060.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/zl38060.c b/sound/soc/codecs/zl38060.c
index 02757ae2b58b..fc67999c84e4 100644
--- a/sound/soc/codecs/zl38060.c
+++ b/sound/soc/codecs/zl38060.c
@@ -534,7 +534,7 @@ static int zl38_bus_write(void *context, const void *data, size_t count)
memcpy(buf + len, data8 + 2, val_len);
len += val_len;
- return spi_write(spi, buf, len);
+ return spi_write_then_read(spi, buf, len, NULL, 0);
}
static const struct regmap_bus zl38_regmap_bus = {
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 22:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 22:25 [PATCH] ASoC: zl38060: use bounce-buffered spi_write_then_read in bus write Elkin Cruz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®