mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ilia Snezhkov via B4 Relay <devnull+iasnezhkov.gmail.com@kernel.org>
To: broonie@kernel.org, lgirdwood@gmail.com
Cc: perex@perex.cz, tiwai@suse.com, matthias.bgg@gmail.com,
	 angelogioacchino.delregno@collabora.com,
	linux-sound@vger.kernel.org,  linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: mediatek: mtk-btcvsd: guard against 0xdeadfeed in btcvsd_tx_clean_buffer()
Date: Wed, 25 Nov 2026 23:48:30 +0000	[thread overview]
Message-ID: <20261125234830.94895-1-iasnezhkov@gmail.com> (raw)

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)




                 reply	other threads:[~2026-11-25 23:48 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=20261125234830.94895-1-iasnezhkov@gmail.com \
    --to=devnull+iasnezhkov.gmail.com@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=broonie@kernel.org \
    --cc=iasnezhkov@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=perex@perex.cz \
    --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®