mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing
@ 2024-01-08 20:44 Nícolas F. R. A. Prado
  2024-01-09  3:44 ` Chen-Yu Tsai
  2024-01-09  9:53 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Nícolas F. R. A. Prado @ 2024-01-08 20:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Kuninori Morimoto, Liam Girdwood,
	Matthias Brugger, Nícolas F. R. A. Prado via Alsa-devel,
	Rob Herring, Takashi Iwai, linux-arm-kernel, linux-kernel,
	linux-mediatek, linux-sound

Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy
Component via COMP_DUMMY()"), the dai_name field is only populated for
dummy components after the card is registered. This causes a null
pointer dereference in the mt8192-mt6359 sound card driver's probe
function when searching for a dai_name among all the card's dai links.

Verify that the dai_name is non-null before passing it to strcmp. While
at it, also check that there's at least one codec.

Reported-by: "kernelci.org bot" <bot@kernelci.org>
Closes: https://linux.kernelci.org/test/case/id/6582cd6d992645c680e13478/
Fixes: 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

 sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index 5bd6addd1450..bfcb2c486c39 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -1208,7 +1208,8 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 			dai_link->ignore = 0;
 		}
 
-		if (strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0)
+		if (dai_link->num_codecs && dai_link->codecs[0].dai_name &&
+		    strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) == 0)
 			dai_link->ops = &mt8192_rt1015_i2s_ops;
 
 		if (!dai_link->platforms->name)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing
  2024-01-08 20:44 [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing Nícolas F. R. A. Prado
@ 2024-01-09  3:44 ` Chen-Yu Tsai
  2024-01-09  9:53 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2024-01-09  3:44 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: Mark Brown, AngeloGioacchino Del Regno, kernel, Jaroslav Kysela,
	Kuninori Morimoto, Liam Girdwood, Matthias Brugger,
	Nícolas F. R. A. Prado via Alsa-devel, Rob Herring,
	Takashi Iwai, linux-arm-kernel, linux-kernel, linux-mediatek,
	linux-sound

On Tue, Jan 9, 2024 at 4:47 AM Nícolas F. R. A. Prado
<nfraprado@collabora.com> wrote:
>
> Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy
> Component via COMP_DUMMY()"), the dai_name field is only populated for
> dummy components after the card is registered. This causes a null
> pointer dereference in the mt8192-mt6359 sound card driver's probe
> function when searching for a dai_name among all the card's dai links.
>
> Verify that the dai_name is non-null before passing it to strcmp. While
> at it, also check that there's at least one codec.
>
> Reported-by: "kernelci.org bot" <bot@kernelci.org>
> Closes: https://linux.kernelci.org/test/case/id/6582cd6d992645c680e13478/
> Fixes: 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()")
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>

Audio now works again on my MT8192 Hayato.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing
  2024-01-08 20:44 [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing Nícolas F. R. A. Prado
  2024-01-09  3:44 ` Chen-Yu Tsai
@ 2024-01-09  9:53 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-01-09  9:53 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: AngeloGioacchino Del Regno, kernel, Jaroslav Kysela,
	Kuninori Morimoto, Liam Girdwood, Matthias Brugger,
	Nícolas F. R. A. Prado via Alsa-devel, Rob Herring,
	Takashi Iwai, linux-arm-kernel, linux-kernel, linux-mediatek,
	linux-sound

On Mon, 08 Jan 2024 17:44:58 -0300, Nícolas F. R. A. Prado wrote:
> Following commit 13f58267cda3 ("ASoC: soc.h: don't create dummy
> Component via COMP_DUMMY()"), the dai_name field is only populated for
> dummy components after the card is registered. This causes a null
> pointer dereference in the mt8192-mt6359 sound card driver's probe
> function when searching for a dai_name among all the card's dai links.
> 
> Verify that the dai_name is non-null before passing it to strcmp. While
> at it, also check that there's at least one codec.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing
      commit: 4d4e1b6319e5c4425ea3faeaf9a10b8b4c16c1e1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-09  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08 20:44 [PATCH] ASoC: mediatek: mt8192: Check existence of dai_name before dereferencing Nícolas F. R. A. Prado
2024-01-09  3:44 ` Chen-Yu Tsai
2024-01-09  9:53 ` Mark Brown

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®