Răsfoiți Sursa

[ALSA] sound/core/: fix 3 off-by-one errors

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>
Adrian Bunk 19 ani în urmă
părinte
comite
3a63e44420
2 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 2 2
      sound/core/sound.c
  2. 1 1
      sound/core/sound_oss.c

+ 2 - 2
sound/core/sound.c

@@ -121,7 +121,7 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
 	struct snd_minor *mreg;
 	struct snd_minor *mreg;
 	void *private_data;
 	void *private_data;
 
 
-	if (minor > ARRAY_SIZE(snd_minors))
+	if (minor >= ARRAY_SIZE(snd_minors))
 		return NULL;
 		return NULL;
 	mutex_lock(&sound_mutex);
 	mutex_lock(&sound_mutex);
 	mreg = snd_minors[minor];
 	mreg = snd_minors[minor];
@@ -140,7 +140,7 @@ static int snd_open(struct inode *inode, struct file *file)
 	struct file_operations *old_fops;
 	struct file_operations *old_fops;
 	int err = 0;
 	int err = 0;
 
 
-	if (minor > ARRAY_SIZE(snd_minors))
+	if (minor >= ARRAY_SIZE(snd_minors))
 		return -ENODEV;
 		return -ENODEV;
 	mptr = snd_minors[minor];
 	mptr = snd_minors[minor];
 	if (mptr == NULL) {
 	if (mptr == NULL) {

+ 1 - 1
sound/core/sound_oss.c

@@ -46,7 +46,7 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
 	struct snd_minor *mreg;
 	struct snd_minor *mreg;
 	void *private_data;
 	void *private_data;
 
 
-	if (minor > ARRAY_SIZE(snd_oss_minors))
+	if (minor >= ARRAY_SIZE(snd_oss_minors))
 		return NULL;
 		return NULL;
 	mutex_lock(&sound_oss_mutex);
 	mutex_lock(&sound_oss_mutex);
 	mreg = snd_oss_minors[minor];
 	mreg = snd_oss_minors[minor];