Skip to content

Commit

Permalink
usb: core: add sanity checks when using bInterfaceClass with new_id
Browse files Browse the repository at this point in the history
Check if that field is actually used and if so, bail out if it exeeds a
u8. Make it also future-proof by not requiring "exactly three"
parameters in new_id, but simply "more than two".

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Wolfram Sang authored and Greg Kroah-Hartman committed Jan 11, 2014
1 parent 3569843 commit c63fe8f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids,
dynid->id.idVendor = idVendor;
dynid->id.idProduct = idProduct;
dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE;
if (fields == 3) {
if (fields > 2 && bInterfaceClass) {
if (bInterfaceClass > 255)
return -EINVAL;

dynid->id.bInterfaceClass = (u8)bInterfaceClass;
dynid->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
}
Expand Down

0 comments on commit c63fe8f

Please sign in to comment.