Skip to contentSkip to conversation

joystick: off by one error

PATCH In review Dan Carpenter 1 participant 2 messages Mar 6, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 joystick: off by one error

This fixes a smatch warning:
drivers/input/joystick/gamecon.c +838 gc_setup_pad(23) error: buffer overflow 'gc_names' 10 <= 10

drivers/input/joystick/gamecon.c +1 -1
index ae998d9..7a55714 100644
@@ -819,7 +819,7 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
 	int i;
 	int err;
 
-	if (pad_type < 1 || pad_type > GC_MAX) {
+	if (pad_type < 1 || pad_type >= GC_MAX) {
 		pr_err("Pad type %d unknown\n", pad_type);
 		return -EINVAL;
 	}
#1 lore raw
Quoted 3 lines · Dan Carpenter

This fixes a smatch warning:
drivers/input/joystick/gamecon.c +838 gc_setup_pad(23) error: buffer overflow 'gc_names' 10 <= 10

Crap. I already sent this patch. I'm really sorry about that.

I will fix my QC process to not do this again.

regards,
dan carpenter

Quoted 15 lines
drivers/input/joystick/gamecon.c +1 -1
index ae998d9..7a55714 100644
@@ -819,7 +819,7 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
 	int i;
 	int err;
 
-	if (pad_type < 1 || pad_type > GC_MAX) {
+	if (pad_type < 1 || pad_type >= GC_MAX) {
 		pr_err("Pad type %d unknown\n", pad_type);
 		return -EINVAL;
 	}