[PATCH] ASoC: zl38060: use bounce-buffered spi_write_then_read in bus write
From: Elkin Cruz
Date: Wed Nov 25 2026 - 17:26:32 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Elkin Cruz <elkin@xxxxxxxxxx>
---
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