Skip to content

Commit

Permalink
USB: CDC ACM: Fix NULL pointer dereference
Browse files Browse the repository at this point in the history
If a device specifies zero endpoints in its interface descriptor,
the kernel oopses in acm_probe(). Even though that's clearly an
invalid descriptor, we should test wether we have all endpoints.
This is especially bad as this oops can be triggered by just
plugging a USB device in.

Signed-off-by: Sven Schnelle <svens@stackframe.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sven Schnelle authored and Greg Kroah-Hartman committed Aug 18, 2012
1 parent 83957df commit 99f347c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,8 @@ static int acm_probe(struct usb_interface *intf,
}


if (data_interface->cur_altsetting->desc.bNumEndpoints < 2)
if (data_interface->cur_altsetting->desc.bNumEndpoints < 2 ||
control_interface->cur_altsetting->desc.bNumEndpoints == 0)
return -EINVAL;

epctrl = &control_interface->cur_altsetting->endpoint[0].desc;
Expand Down

0 comments on commit 99f347c

Please sign in to comment.