[PATCH AUTOSEL 6.0 30/39] ASoC: soc-pcm: Add NULL check in BE reparenting

From: Sasha Levin
Date: Mon Nov 28 2022 - 12:41:35 EST


From: Srinivasa Rao Mandadapu <quic_srivasam@xxxxxxxxxxx>

[ Upstream commit db8f91d424fe0ea6db337aca8bc05908bbce1498 ]

Add NULL check in dpcm_be_reparent API, to handle
kernel NULL pointer dereference error.
The issue occurred in fuzzing test.

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@xxxxxxxxxxx>
Link: https://lore.kernel.org/r/1669098673-29703-1-git-send-email-quic_srivasam@xxxxxxxxxxx
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
sound/soc/soc-pcm.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 4d9b91e7e14f..91a1bfe00d9b 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1247,6 +1247,8 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe,
return;

be_substream = snd_soc_dpcm_get_substream(be, stream);
+ if (!be_substream)
+ return;

for_each_dpcm_fe(be, stream, dpcm) {
if (dpcm->fe == fe)
--
2.35.1