Commit aea1ae87 authored by Johan Hovold's avatar Johan Hovold

USB: ftdi_sio: fix null deref at port probe

Fix NULL-pointer dereference when probing an interface with no
endpoints.

These devices have two bulk endpoints per interface, but this avoids
crashing the kernel if a user forces a non-FTDI device to be probed.

Note that the iterator variable was made unsigned in order to avoid
a maybe-uninitialized compiler warning for ep_desc after the loop.

Fixes: 895f28ba ("USB: ftdi_sio: fix hi-speed device packet size
calculation")
Reported-by: default avatarMike Remski <mremski@mutualink.net>
Tested-by: default avatarMike Remski <mremski@mutualink.net>
Cc: <stable@vger.kernel.org>	# 2.6.31
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 53066e3a
...@@ -1566,14 +1566,17 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port) ...@@ -1566,14 +1566,17 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
struct usb_device *udev = serial->dev; struct usb_device *udev = serial->dev;
struct usb_interface *interface = serial->interface; struct usb_interface *interface = serial->interface;
struct usb_endpoint_descriptor *ep_desc = &interface->cur_altsetting->endpoint[1].desc; struct usb_endpoint_descriptor *ep_desc;
unsigned num_endpoints; unsigned num_endpoints;
int i; unsigned i;
num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints); dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);
if (!num_endpoints)
return;
/* NOTE: some customers have programmed FT232R/FT245R devices /* NOTE: some customers have programmed FT232R/FT245R devices
* with an endpoint size of 0 - not good. In this case, we * with an endpoint size of 0 - not good. In this case, we
* want to override the endpoint descriptor setting and use a * want to override the endpoint descriptor setting and use a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment