* [PATCH] ASoC: mediatek: mtk-btcvsd: guard against 0xdeadfeed in btcvsd_tx_clean_buffer()
@ 2026-11-25 23:48 Ilia Snezhkov via B4 Relay
0 siblings, 0 replies; only message in thread
From: Ilia Snezhkov via B4 Relay @ 2026-11-25 23:48 UTC (permalink / raw)
To: broonie, lgirdwood
Cc: perex, tiwai, matthias.bgg, angelogioacchino.delregno,
linux-sound, linux-mediatek, linux-arm-kernel, linux-kernel
From: Ilia Snezhkov <iasnezhkov@gmail.com>
mtk_btcvsd_read_from_bt() and mtk_btcvsd_write_to_bt() both reject the
0xdeadfeed sentinel returned by the BT connsys SRAM pointer register
when BT SRAM is unpowered or resetting, and check the SRAM address
before dereferencing it. btcvsd_tx_clean_buffer(), however, casts each
stored bt_sram_addr[] entry straight to a pointer and writes mute frames
through mtk_btcvsd_snd_data_transfer() without checking for 0xdeadfeed
or NULL.
If an invalid or reset SRAM address is recorded or cleared concurrently
around hw_free / mute transitions, btcvsd_tx_clean_buffer() dereferences
an invalid address in atomic context under tx_lock.
Skip any bt_sram_addr[] slot holding 0xdeadfeed or 0 before transferring
mute data.
Found and drafted with an AI coding assistant while bringing up MT6789.
Fixes: 4bd8597dc36c ("ASoC: mediatek: add btcvsd driver")
Fixes: d067b3378a78 ("ASoC: mediatek: mtk-btcvsd: Add checks for write and read of mtk_btcvsd_snd")
Signed-off-by: Ilia Snezhkov <iasnezhkov@gmail.com>
---
sound/soc/mediatek/common/mtk-btcvsd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c
index 19329dd..1f52567 100644
--- a/sound/soc/mediatek/common/mtk-btcvsd.c
+++ b/sound/soc/mediatek/common/mtk-btcvsd.c
@@ -341,6 +341,10 @@ static int btcvsd_tx_clean_buffer(struct mtk_btcvsd_snd *bt)
dev_info(bt->dev, "%s(), clean addr 0x%lx\n", __func__,
bt->tx->buffer_info.bt_sram_addr[i]);
+ if (bt->tx->buffer_info.bt_sram_addr[i] == 0xdeadfeed ||
+ !bt->tx->buffer_info.bt_sram_addr[i])
+ continue;
+
dst = (void *)bt->tx->buffer_info.bt_sram_addr[i];
mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_ARM2BT,
--
2.54.0 (Apple Git-157)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 23:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 23:48 [PATCH] ASoC: mediatek: mtk-btcvsd: guard against 0xdeadfeed in btcvsd_tx_clean_buffer() Ilia Snezhkov via B4 Relay
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®