From: Elkin Cruz <elkin@google.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, irogers@google.com,
Elkin Cruz <elkin@google.com>,
stable@vger.kernel.org
Subject: [PATCH] ASoC: zl38060: use bounce-buffered spi_write_then_read in bus write
Date: Wed, 25 Nov 2026 22:25:36 +0000 [thread overview]
Message-ID: <20261125222536.1447211-1-elkin@google.com> (raw)
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
reply other threads:[~2026-11-25 22:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261125222536.1447211-1-elkin@google.com \
--to=elkin@google.com \
--cc=broonie@kernel.org \
--cc=irogers@google.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.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
all inboxes | Powered by JetHome®