Skip to contentSkip to conversation

Check sound_alloc_mixerdev() failure in sound/oss/nm256_audio.c

PATCH In review Eric Sesterhenn 2 participants 3 messages Jun 1, 2006 – Jun 5, 2006 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check sound_alloc_mixerdev() failure in sound/oss/nm256_audio.c

hi,

this was spotted by coverity, bug id #395.
When sound_alloc_mixerdev() fails it returns a
negative value, which the driver fails to check.

sound/oss/nm256_audio.c renamed from sound/oss/nm256_audio.c.orig +1 -1
@@ -974,7 +974,7 @@ nm256_install_mixer (struct nm256_info *
 	return -1;
 
     mixer = sound_alloc_mixerdev();
-    if (num_mixers >= MAX_MIXER_DEV) {
+    if ((num_mixers >= MAX_MIXER_DEV) || (num_mixers < 0)) {
 	printk ("NM256 mixer: Unable to alloc mixerdev\n");
 	return -1;
     }
#1 lore raw
Quoted 2 lines · Eric Sesterhenn

When sound_alloc_mixerdev() fails it returns a
negative value, which the driver fails to check.

That's true.

sound/oss/nm256_audio.c nm256_install_mixer (struct nm256_info * · line 976

Quoted 6 lines
sound/oss/nm256_audio.c renamed from sound/oss/nm256_audio.c.orig +0 -0
@@ -974,7 +974,7 @@ nm256_install_mixer (struct nm256_info *
 	return -1;
 
     mixer = sound_alloc_mixerdev();
       ^^^^^

sound/oss/nm256_audio.c nm256_install_mixer (struct nm256_info * · line 977

Quoted 2 lines
sound/oss/nm256_audio.c renamed from sound/oss/nm256_audio.c.orig +1 -1
-    if (num_mixers >= MAX_MIXER_DEV) {
+    if ((num_mixers >= MAX_MIXER_DEV) || (num_mixers < 0)) {
					     ^^^^^^^^^^

sound/oss/nm256_audio.c nm256_install_mixer (struct nm256_info * · line 980

Quoted 3 lines
sound/oss/nm256_audio.c renamed from sound/oss/nm256_audio.c.orig +0 -0
 	printk ("NM256 mixer: Unable to alloc mixerdev\n");
 	return -1;
     }

But it is _still_ fails to check it.

#2 lore raw

hi,

Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-    if (num_mixers >= MAX_MIXER_DEV) {
+    if ((num_mixers >= MAX_MIXER_DEV) || (num_mixers < 0)) {
					     ^^^^^^^^^^

Review

Quoted 3 lines
(quoted diff) +0 -0
 	printk ("NM256 mixer: Unable to alloc mixerdev\n");
 	return -1;
     }

But it is _still_ fails to check it.

*yuck* I hope you keep count on the numbers of beers i owe you by now. Here is an updated patch.

sound/oss/nm256_audio.c renamed from sound/oss/nm256_audio.c.orig +1 -1
@@ -974,7 +974,7 @@ nm256_install_mixer (struct nm256_info *
 	return -1;
 
     mixer = sound_alloc_mixerdev();
-    if (num_mixers >= MAX_MIXER_DEV) {
+    if ((num_mixers >= MAX_MIXER_DEV) || (mixer < 0)) {
 	printk ("NM256 mixer: Unable to alloc mixerdev\n");
 	return -1;
     }