Skip to contentSkip to conversation

ALSA: pcm_native.c initialize drec and num_drecs before it get used

RFC PATCH In review Jaswinder Singh Rajput 2 participants 2 messages Sep 12, 2009 – Sep 14, 2009 Sound

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ALSA: pcm_native.c initialize drec and num_drecs before it get used

[This is untested]

drec and num_drecs is used uninitialized for nonblock(goto lock)

This also fixed following compilation warnings :

CC [M] sound/core/pcm_native.o
sound/core/pcm_native.c: In function ‘snd_pcm_drain’:
sound/core/pcm_native.c:1413: warning: ‘drec’ may be used uninitialized in this function sound/core/pcm_native.c:1411: warning: ‘num_drecs’ may be used uninitialized in this function

---
 sound/core/pcm_native.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
sound/core/pcm_native.c +4 -3
index 59e5fbe..8284dc1 100644
@@ -1433,6 +1433,9 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
 	} else if (substream->f_flags & O_NONBLOCK)
 		nonblock = 1;
 
+	drec = &drec_tmp;
+	num_drecs = 0;
+
 	if (nonblock)
 		goto lock; /* no need to allocate waitqueues */
 
@@ -1445,11 +1448,9 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
 			snd_power_unlock(card);
 			return -ENOMEM;
 		}
-	} else
-		drec = &drec_tmp;
+	}
 
 	/* count only playback streams */
-	num_drecs = 0;
 	snd_pcm_group_for_each_entry(s, substream) {
 		runtime = s->runtime;
 		if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
Signature · 7 lines
1.6.4.2


_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw

At Sat, 12 Sep 2009 23:47:45 +0530,

Quoted 11 lines · Jaswinder Singh Rajput

[This is untested]

drec and num_drecs is used uninitialized for nonblock(goto lock)

This also fixed following compilation warnings :

CC [M] sound/core/pcm_native.o
sound/core/pcm_native.c: In function ‘snd_pcm_drain’:
sound/core/pcm_native.c:1413: warning: ‘drec’ may be used uninitialized in this function sound/core/pcm_native.c:1411: warning: ‘num_drecs’ may be used uninitialized in this function

This is false-positive.
I'm going to give another try to shut gcc out later.

thanks,

Takashi

Quoted 37 lines
---
 sound/core/pcm_native.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
sound/core/pcm_native.c +4 -3
index 59e5fbe..8284dc1 100644
@@ -1433,6 +1433,9 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
 	} else if (substream->f_flags & O_NONBLOCK)
 		nonblock = 1;
 
+	drec = &drec_tmp;
+	num_drecs = 0;
+
 	if (nonblock)
 		goto lock; /* no need to allocate waitqueues */
 
@@ -1445,11 +1448,9 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
 			snd_power_unlock(card);
 			return -ENOMEM;
 		}
-	} else
-		drec = &drec_tmp;
+	}
 
 	/* count only playback streams */
-	num_drecs = 0;
 	snd_pcm_group_for_each_entry(s, substream) {
 		runtime = s->runtime;
 		if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
Signature · 1 line
1.6.4.2

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel