Skip to content

Commit

Permalink
USB: ftdi_sio: fix null deref at port probe
Browse files Browse the repository at this point in the history
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: 895f28b ("USB: ftdi_sio: fix hi-speed device packet size
calculation")

Reported-by: Mike Remski <[email protected]>
Tested-by: Mike Remski <[email protected]>
Cc: <[email protected]>	# 2.6.31
Signed-off-by: Johan Hovold <[email protected]>
  • Loading branch information
jhovold committed Jun 23, 2014
1 parent 53066e3 commit aea1ae8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,14 +1566,17 @@ static void ftdi_set_max_packet_size(struct usb_serial_port *port)
struct usb_device *udev = serial->dev;

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;
int i;
unsigned i;

num_endpoints = interface->cur_altsetting->desc.bNumEndpoints;
dev_info(&udev->dev, "Number of endpoints %d\n", num_endpoints);

if (!num_endpoints)
return;

/* NOTE: some customers have programmed FT232R/FT245R devices
* with an endpoint size of 0 - not good. In this case, we
* want to override the endpoint descriptor setting and use a
Expand Down

0 comments on commit aea1ae8

Please sign in to comment.