Skip to contentSkip to conversation

Fix off-by-one for num_values in uref_multi requests

PATCH Applied Ben Collins 2 participants 2 messages Jan 30, 2006 – Jan 31, 2006 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix off-by-one for num_values in uref_multi requests

Found this when working with a HAPP UGCI device. It has a usage with 7 indexes. I could read them all one at a time, but using a multiref it would only allow me to read the first 6. The patch below fixed it.

drivers/usb/input/hiddev.c +1 -1
@@ -632,7 +632,7 @@ static int hiddev_ioctl(struct inode *in
 
 			else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
 				 (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
-				  uref->usage_index + uref_multi->num_values >= field->report_count))
+				  uref->usage_index + uref_multi->num_values > field->report_count))
 				goto inval;
 			}
 
Signature · 2 lines
Ben Collins
Kernel Developer - Ubuntu Linux
#1 lore raw
Quoted 6 lines · Ben Collins

Found this when working with a HAPP UGCI device. It has a usage with 7 indexes. I could read them all one at a time, but using a multiref it would only allow me to read the first 6. The patch below fixed it.

I applied this to the input tree, thanks!

Quoted 12 lines
drivers/usb/input/hiddev.c +1 -1
@@ -632,7 +632,7 @@ static int hiddev_ioctl(struct inode *in
 
 			else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
 				 (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
-				  uref->usage_index + uref_multi->num_values >= field->report_count))
+				  uref->usage_index + uref_multi->num_values > field->report_count))
 				goto inval;
 			}
 
Signature · 1 line
Dmitry