From: Alan Stern Date: Fri, 29 Sep 2017 14:54:24 +0000 (-0400) Subject: usb: usbtest: fix NULL pointer dereference X-Git-Tag: v4.1.12-124.31.3~1076 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=89a853b3ec4200629c82357e223fb9a94176800f;p=users%2Fjedix%2Flinux-maple.git usb: usbtest: fix NULL pointer dereference If the usbtest driver encounters a device with an IN bulk endpoint but no OUT bulk endpoint, it will try to dereference a NULL pointer (out->desc.bEndpointAddress). The problem can be solved by adding a missing test. Signed-off-by: Alan Stern Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Felipe Balbi (cherry picked from commit 7c80f9e4a588f1925b07134bb2e3689335f6c6d8) Orabug: 27602322 CVE: CVE-2017-16532 Signed-off-by: Tim Tianyang Chen Reviewed-by: Ashok Vairavan --- diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 0bbafe795a72..a7a85dd82d35 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -182,12 +182,13 @@ found: return tmp; } - if (in) { + if (in) dev->in_pipe = usb_rcvbulkpipe(udev, in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); + if (out) dev->out_pipe = usb_sndbulkpipe(udev, out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); - } + if (iso_in) { dev->iso_in = &iso_in->desc; dev->in_iso_pipe = usb_rcvisocpipe(udev,