aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-04-03 07:06:46 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-31 00:52:13 -0400
commit9781c6a26a489c54b53ca31ca227e8423e76693a (patch)
tree750e4cbb15e5ea988b59104c8218e0730ac044cb
parent05fdd16c9f90522fcf4b56dbd33e9ab92c0bf2ea (diff)
USB: usb_wwan: fix handling of missing bulk endpoints
commit bd73bd8831696f189a479a0712ae95208e513d7e upstream. Fix regression introduced by commit 8e493ca1767d ("USB: usb_wwan: fix bulk-urb allocation") by making sure to require both bulk-in and out endpoints during port probe. The original option driver (which usb_wwan is based on) was written under the assumption that either endpoint could be missing, but evidently this cannot have been tested properly. Specifically, it would handle opening a device without bulk-in (but would blow up during resume which was implemented later), but not a missing bulk-out in write() (although it is handled in some places such as write_room()). Fortunately (?), the driver also got the test for missing endpoints wrong so the urbs were in fact always allocated, although they would be initialised using the wrong endpoint address (0) and any submission of such an urb would fail. The commit mentioned above fixed the test for missing endpoints but thereby exposed the other bugs which would now generate null-pointer exceptions rather than failed urb submissions. The regression was introduced in v3.7, but the offending commit was also marked for stable. Reported-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Johan Hovold <jhovold@gmail.com> Tested-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/usb_wwan.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index db0cf536de18..11952b6dc224 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -470,6 +470,9 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
470 int err; 470 int err;
471 int i; 471 int i;
472 472
473 if (!port->bulk_in_size || !port->bulk_out_size)
474 return -ENODEV;
475
473 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 476 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
474 if (!portdata) 477 if (!portdata)
475 return -ENOMEM; 478 return -ENOMEM;
@@ -477,9 +480,6 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
477 init_usb_anchor(&portdata->delayed); 480 init_usb_anchor(&portdata->delayed);
478 481
479 for (i = 0; i < N_IN_URB; i++) { 482 for (i = 0; i < N_IN_URB; i++) {
480 if (!port->bulk_in_size)
481 break;
482
483 buffer = (u8 *)__get_free_page(GFP_KERNEL); 483 buffer = (u8 *)__get_free_page(GFP_KERNEL);
484 if (!buffer) 484 if (!buffer)
485 goto bail_out_error; 485 goto bail_out_error;
@@ -493,9 +493,6 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
493 } 493 }
494 494
495 for (i = 0; i < N_OUT_URB; i++) { 495 for (i = 0; i < N_OUT_URB; i++) {
496 if (!port->bulk_out_size)
497 break;
498
499 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); 496 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL);
500 if (!buffer) 497 if (!buffer)
501 goto bail_out_error2; 498 goto bail_out_error2;