[alsa-devel] [PATCH 1/6] ALSA: pcm: check parameter on snd_pcm_running()

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Thu Nov 9 03:11:54 CET 2017


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

snd_pcm_running() is using "substream" and "substream->runtime"
pointer. Let's check it before use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/pcm.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 24febf9..a8e49f5 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -664,6 +664,9 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,
  */
 static inline int snd_pcm_running(struct snd_pcm_substream *substream)
 {
+	if (!substream || !substream->runtime)
+		return 0;
+
 	return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING ||
 		(substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING &&
 		 substream->stream == SNDRV_PCM_STREAM_PLAYBACK));
-- 
1.9.1



More information about the Alsa-devel mailing list