From: Alan Stern Date: Mon, 5 Oct 2009 19:53:58 +0000 (-0400) Subject: USB: ipaq: fix oops when device is plugged in X-Git-Tag: v2.6.31.5~32 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1a0da0e58df9667ec9b77c4c222a380c23344977;p=karo-tx-linux.git USB: ipaq: fix oops when device is plugged in commit 06bad89da686f6323e95cf925105e8cf88d87caf upstream. This patch (as1293) fixes a problem with the ipaq serial driver. It tries to bind to all the interfaces, even those that don't have enough endpoints. The symptom is an invalid memory reference and oops when the device is plugged in. Signed-off-by: Alan Stern Tested-by: Matthias Geissert Tested-by: Tilman Schmidt Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 2545d45ce16f..c4d02064e5f1 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -971,6 +971,15 @@ static int ipaq_calc_num_ports(struct usb_serial *serial) static int ipaq_startup(struct usb_serial *serial) { dbg("%s", __func__); + + /* Some of the devices in ipaq_id_table[] are composite, and we + * shouldn't bind to all the interfaces. This test will rule out + * some obviously invalid possibilities. + */ + if (serial->num_bulk_in < serial->num_ports || + serial->num_bulk_out < serial->num_ports) + return -ENODEV; + if (serial->dev->actconfig->desc.bConfigurationValue != 1) { /* * FIXME: HP iPaq rx3715, possibly others, have 1 config that