Skip to contentSkip to conversation

ALSA: core: fix NULL checking in snd_pcm_plug_client_size()

PATCH Applied Xi Wang 2 participants 3 messages Nov 13, 2012 – Nov 14, 2012 Sound

lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/2 ALSA: core: fix NULL checking in snd_pcm_plug_client_size()

The dereference snd_pcm_plug_stream(plug) should come after the NULL check snd_BUG_ON(!plug).

---
 sound/core/oss/pcm_plugin.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +2 -1
index 71cc3dd..f0d7b15 100644
@@ -199,12 +199,13 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
 snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames)
 {
 	struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
-	int stream = snd_pcm_plug_stream(plug);
+	int stream;
 
 	if (snd_BUG_ON(!plug))
 		return -ENXIO;
 	if (drv_frames == 0)
 		return 0;
+	stream = snd_pcm_plug_stream(plug);
 	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		plugin = snd_pcm_plug_last(plug);
 		while (plugin && drv_frames > 0) {
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 2/2 ALSA: core: fix NULL checking in snd_pcm_plug_slave_size()

The dereference snd_pcm_plug_stream(plug) should come after the NULL check snd_BUG_ON(!plug).

---
 sound/core/oss/pcm_plugin.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +2 -1
index f0d7b15..727ac44 100644
@@ -231,13 +231,14 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
 {
 	struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
 	snd_pcm_sframes_t frames;
-	int stream = snd_pcm_plug_stream(plug);
+	int stream;
 	
 	if (snd_BUG_ON(!plug))
 		return -ENXIO;
 	if (clt_frames == 0)
 		return 0;
 	frames = clt_frames;
+	stream = snd_pcm_plug_stream(plug);
 	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		plugin = snd_pcm_plug_first(plug);
 		while (plugin && frames > 0) {
Signature · 1 line
1.7.10.4
Applied
#2 lore raw
In reply to Xi Wang

At Tue, 13 Nov 2012 17:12:11 -0500,

Quoted 5 lines · Xi Wang

The dereference snd_pcm_plug_stream(plug) should come after the NULL check snd_BUG_ON(!plug).

Applied both patches. Thanks.

Takashi

Quoted 26 lines
---
 sound/core/oss/pcm_plugin.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/oss/pcm_plugin.c +2 -1
index 71cc3dd..f0d7b15 100644
@@ -199,12 +199,13 @@ int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin)
 snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames)
 {
 	struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
-	int stream = snd_pcm_plug_stream(plug);
+	int stream;
 
 	if (snd_BUG_ON(!plug))
 		return -ENXIO;
 	if (drv_frames == 0)
 		return 0;
+	stream = snd_pcm_plug_stream(plug);
 	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		plugin = snd_pcm_plug_last(plug);
 		while (plugin && drv_frames > 0) {
Signature · 1 line
1.7.10.4