From: Sven Schnelle Date: Fri, 17 Aug 2012 19:43:43 +0000 (+0200) Subject: USB: CDC ACM: Fix NULL pointer dereference X-Git-Tag: v2.6.39-400.9.0~299^2~13 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=119b8ece47299941d2c24de9c29baebb626fd8ba;p=users%2Fjedix%2Flinux-maple.git USB: CDC ACM: Fix NULL pointer dereference commit 99f347caa4568cb803862730b3b1f1942639523f upstream. 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 496e06e5fa66..de80171f9582 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1043,7 +1043,8 @@ skip_normal_probe: } - 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;