All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.de>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>, Simon <horms@verge.net.au>
Subject: [PATCH 1/6] ALSA: pcm: check parameter on snd_pcm_running()
Date: Thu, 9 Nov 2017 02:11:54 +0000	[thread overview]
Message-ID: <87po8sp5sr.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87r2t8p5tz.wl%kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@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@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

  reply	other threads:[~2017-11-09  2:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09  2:11 [PATCH 0/6] ALSA: pcm: check parameter on snd_pcm_running() Kuninori Morimoto
2017-11-09  2:11 ` Kuninori Morimoto [this message]
2017-11-09  2:12 ` [PATCH 2/6] ALSA: pdaudiocf: remove unneeded check for snd_pcm_running() Kuninori Morimoto
2017-11-09  2:12 ` [PATCH 3/6] ASoC: dwc: " Kuninori Morimoto
2017-11-09  2:12 ` [PATCH 4/6] ASoC: omap-hdmi-audio: " Kuninori Morimoto
2017-11-09  2:14 ` [PATCH 5/6] ASoC: xtfpga-i2s: " Kuninori Morimoto
2017-11-09  2:15 ` [PATCH 6/6] ASoC: rsnd: " Kuninori Morimoto
2017-11-09  2:40 ` [PATCH 0/6] ALSA: pcm: check parameter on snd_pcm_running() Takashi Sakamoto
2017-11-09  7:41   ` Takashi Iwai
2017-11-28  6:33     ` Kuninori Morimoto
2017-11-28  6:42       ` Takashi Iwai
2017-11-28  6:53         ` Kuninori Morimoto

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=87po8sp5sr.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=horms@verge.net.au \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.