diff mbox series

ASoC: SOF: amd: Fix NULL pointer crash in acp_sof_ipc_msg_data function

Message ID 168352953853.26.8164483983661499361@mailman-core.alsa-project.org (mailing list archive)
State Accepted
Commit 051d71e073614a72ad423d6dacba37a7eeff274d
Headers show
Series ASoC: SOF: amd: Fix NULL pointer crash in acp_sof_ipc_msg_data function | expand

Commit Message

V sujith kumar Reddy May 8, 2023, 7:05 a.m. UTC
Check substream and runtime variables before assigning.

Signed-off-by: V sujith kumar Reddy <Vsujithkumar.Reddy@amd.com>
---
 sound/soc/sof/amd/acp-ipc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/soc/sof/amd/acp-ipc.c b/sound/soc/sof/amd/acp-ipc.c
index 4e0c48a36159..749e856dc601 100644
--- a/sound/soc/sof/amd/acp-ipc.c
+++ b/sound/soc/sof/amd/acp-ipc.c
@@ -209,7 +209,12 @@  int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_sof_pcm_stream *sp
 		acp_mailbox_read(sdev, offset, p, sz);
 	} else {
 		struct snd_pcm_substream *substream = sps->substream;
-		struct acp_dsp_stream *stream = substream->runtime->private_data;
+		struct acp_dsp_stream *stream;
+
+		if (!substream || !substream->runtime)
+			return -ESTRPIPE;
+
+		stream = substream->runtime->private_data;
 
 		if (!stream)
 			return -ESTRPIPE;