[PATCH] Fix sb_mixer use before validation
authorEugene Teo <eugene.teo@eugeneteo.net>
Sat, 25 Mar 2006 11:08:07 +0000 (03:08 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 25 Mar 2006 16:22:59 +0000 (08:22 -0800)
dev should be validated before it is being used as index to array.

Coverity bug #871

Signed-off-by: Eugene Teo <eugene.teo@eugeneteo.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
sound/oss/sb_mixer.c

index f56898c..ccb21d4 100644 (file)
@@ -273,14 +273,14 @@ int sb_common_mixer_set(sb_devc * devc, int dev, int left, int right)
        int regoffs;
        unsigned char val;
 
+       if ((dev < 0) || (dev >= devc->iomap_sz))
+               return -EINVAL;
+
        regoffs = (*devc->iomap)[dev][LEFT_CHN].regno;
 
        if (regoffs == 0)
                return -EINVAL;
 
-       if ((dev < 0) || (dev >= devc->iomap_sz))
-           return -EINVAL;
-
        val = sb_getmixer(devc, regoffs);
        change_bits(devc, &val, dev, LEFT_CHN, left);