[ALSA] sound/core/: fix 3 off-by-one errors
authorAdrian Bunk <bunk@stusta.de>
Mon, 13 Mar 2006 13:14:10 +0000 (14:14 +0100)
committerJaroslav Kysela <perex@suse.cz>
Wed, 22 Mar 2006 09:37:31 +0000 (10:37 +0100)
Modules: ALSA Core

This patch fixes three off-by-one errors found by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/sound.c
sound/core/sound_oss.c

index df4ab94d006e0f191058c6a9cb566310d3090188..4d28e52126118bbc57659825ac6b93579de18a88 100644 (file)
@@ -121,7 +121,7 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
        struct snd_minor *mreg;
        void *private_data;
 
-       if (minor > ARRAY_SIZE(snd_minors))
+       if (minor >= ARRAY_SIZE(snd_minors))
                return NULL;
        mutex_lock(&sound_mutex);
        mreg = snd_minors[minor];
@@ -140,7 +140,7 @@ static int snd_open(struct inode *inode, struct file *file)
        struct file_operations *old_fops;
        int err = 0;
 
-       if (minor > ARRAY_SIZE(snd_minors))
+       if (minor >= ARRAY_SIZE(snd_minors))
                return -ENODEV;
        mptr = snd_minors[minor];
        if (mptr == NULL) {
index 6b4a4bccd8fee4b5ec0bc05832c44df71bfcd976..4023d3b406de2c22613bcfc6811e4c83193584cd 100644 (file)
@@ -46,7 +46,7 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
        struct snd_minor *mreg;
        void *private_data;
 
-       if (minor > ARRAY_SIZE(snd_oss_minors))
+       if (minor >= ARRAY_SIZE(snd_oss_minors))
                return NULL;
        mutex_lock(&sound_oss_mutex);
        mreg = snd_oss_minors[minor];