OSDN Git Service

Merge "hid: usbhid: Changes to prevent buffer overflow"
authorLinux Build Service Account <lnxbuild@localhost>
Mon, 9 Jul 2018 19:30:23 +0000 (12:30 -0700)
committerGerrit - the friendly Code Review server <code-review@localhost>
Mon, 9 Jul 2018 19:30:22 +0000 (12:30 -0700)
drivers/hid/usbhid/hiddev.c

index 700145b..da8fd95 100644 (file)
@@ -510,13 +510,13 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
                                goto inval;
 
                        field = report->field[uref->field_index];
+               }
 
-                       if (cmd == HIDIOCGCOLLECTIONINDEX) {
-                               if (uref->usage_index >= field->maxusage)
-                                       goto inval;
-                       } else if (uref->usage_index >= field->report_count)
+               if (cmd == HIDIOCGCOLLECTIONINDEX) {
+                       if (uref->usage_index >= field->maxusage)
                                goto inval;
-               }
+               } else if (uref->usage_index >= field->report_count)
+                       goto inval;
 
                if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
                    (uref_multi->num_values > HID_MAX_MULTI_USAGES ||