Takashi Iwai d23356
From 7c5a2df3367a2c4984f1300261345817d95b71f8 Mon Sep 17 00:00:00 2001
Takashi Iwai d23356
From: Johan Hovold <johan@kernel.org>
Takashi Iwai d23356
Date: Tue, 10 Dec 2019 12:26:01 +0100
Takashi Iwai d23356
Subject: [PATCH] USB: serial: io_edgeport: fix epic endpoint lookup
Takashi Iwai d23356
Git-commit: 7c5a2df3367a2c4984f1300261345817d95b71f8
Takashi Iwai d23356
Patch-mainline: v5.5-rc2
Takashi Iwai d23356
References: bsc#1051510
Takashi Iwai d23356
Takashi Iwai d23356
Make sure to use the current alternate setting when looking up the
Takashi Iwai d23356
endpoints on epic devices to avoid binding to an invalid interface.
Takashi Iwai d23356
Takashi Iwai d23356
Failing to do so could cause the driver to misbehave or trigger a WARN()
Takashi Iwai d23356
in usb_submit_urb() that kernels with panic_on_warn set would choke on.
Takashi Iwai d23356
Takashi Iwai d23356
Fixes: 6e8cf7751f9f ("USB: add EPIC support to the io_edgeport driver")
Takashi Iwai d23356
Cc: stable <stable@vger.kernel.org>     # 2.6.21
Takashi Iwai d23356
Signed-off-by: Johan Hovold <johan@kernel.org>
Takashi Iwai d23356
Link: https://lore.kernel.org/r/20191210112601.3561-5-johan@kernel.org
Takashi Iwai d23356
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Takashi Iwai d23356
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai d23356
Takashi Iwai d23356
---
Takashi Iwai d23356
 drivers/usb/serial/io_edgeport.c | 10 ++++++----
Takashi Iwai d23356
 1 file changed, 6 insertions(+), 4 deletions(-)
Takashi Iwai d23356
Takashi Iwai d23356
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
Takashi Iwai d23356
index 48a439298a68..9690a5f4b9d6 100644
Takashi Iwai d23356
--- a/drivers/usb/serial/io_edgeport.c
Takashi Iwai d23356
+++ b/drivers/usb/serial/io_edgeport.c
Takashi Iwai d23356
@@ -2901,16 +2901,18 @@ static int edge_startup(struct usb_serial *serial)
Takashi Iwai d23356
 	response = 0;
Takashi Iwai d23356
 
Takashi Iwai d23356
 	if (edge_serial->is_epic) {
Takashi Iwai d23356
+		struct usb_host_interface *alt;
Takashi Iwai d23356
+
Takashi Iwai d23356
+		alt = serial->interface->cur_altsetting;
Takashi Iwai d23356
+
Takashi Iwai d23356
 		/* EPIC thing, set up our interrupt polling now and our read
Takashi Iwai d23356
 		 * urb, so that the device knows it really is connected. */
Takashi Iwai d23356
 		interrupt_in_found = bulk_in_found = bulk_out_found = false;
Takashi Iwai d23356
-		for (i = 0; i < serial->interface->altsetting[0]
Takashi Iwai d23356
-						.desc.bNumEndpoints; ++i) {
Takashi Iwai d23356
+		for (i = 0; i < alt->desc.bNumEndpoints; ++i) {
Takashi Iwai d23356
 			struct usb_endpoint_descriptor *endpoint;
Takashi Iwai d23356
 			int buffer_size;
Takashi Iwai d23356
 
Takashi Iwai d23356
-			endpoint = &serial->interface->altsetting[0].
Takashi Iwai d23356
-							endpoint[i].desc;
Takashi Iwai d23356
+			endpoint = &alt->endpoint[i].desc;
Takashi Iwai d23356
 			buffer_size = usb_endpoint_maxp(endpoint);
Takashi Iwai d23356
 			if (!interrupt_in_found &&
Takashi Iwai d23356
 			    (usb_endpoint_is_int_in(endpoint))) {
Takashi Iwai d23356
-- 
Takashi Iwai d23356
2.16.4
Takashi Iwai d23356