From: Adrian Bunk This patch fixes three off-by-one errors found by the Coverity checker. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton --- sound/core/sound.c | 4 ++-- sound/core/sound_oss.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff -puN sound/core/sound.c~sound-core-fix-3-off-by-one-errors sound/core/sound.c --- devel/sound/core/sound.c~sound-core-fix-3-off-by-one-errors 2006-03-11 01:09:17.000000000 -0800 +++ devel-akpm/sound/core/sound.c 2006-03-11 01:09:17.000000000 -0800 @@ -121,7 +121,7 @@ void *snd_lookup_minor_data(unsigned int 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_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) { diff -puN sound/core/sound_oss.c~sound-core-fix-3-off-by-one-errors sound/core/sound_oss.c --- devel/sound/core/sound_oss.c~sound-core-fix-3-off-by-one-errors 2006-03-11 01:09:17.000000000 -0800 +++ devel-akpm/sound/core/sound_oss.c 2006-03-11 01:09:17.000000000 -0800 @@ -46,7 +46,7 @@ void *snd_lookup_oss_minor_data(unsigned 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]; _