Skip to contentSkip to conversation

sound/core/: fix 3 off-by-one errors

PATCH Applied Adrian Bunk 2 participants 2 messages Mar 11, 2006 – Mar 13, 2006 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/core/: fix 3 off-by-one errors

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

---

 sound/core/sound.c     |    4 ++--
 sound/core/sound_oss.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
sound/core/sound.c renamed from sound/core/sound.c.old +2 -2
@@ -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,
 	const 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) {
sound/core/sound_oss.c renamed from sound/core/sound_oss.c.old +1 -1
@@ -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];

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

Applied
#1 lore raw

At Sat, 11 Mar 2006 04:43:10 +0100,

Quoted 5 lines · Adrian Bunk

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

Thanks, applied both patches to ALSA tree.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642