0c2a2f5
From b2476fe4c16be5c2b7ee950e50677cfaa9ab9bae Mon Sep 17 00:00:00 2001
0c2a2f5
From: Vladis Dronov <vdronov@redhat.com>
0c2a2f5
Date: Tue, 12 Jan 2016 14:10:50 -0500
0c2a2f5
Subject: [PATCH] usb: serial: visor: fix crash on detecting device without
0c2a2f5
 write_urbs
0c2a2f5
0c2a2f5
The visor driver crashes in clie_5_attach() when a specially crafted USB
0c2a2f5
device without bulk-out endpoint is detected. This fix adds a check that
0c2a2f5
the device has proper configuration expected by the driver.
0c2a2f5
0c2a2f5
Reported-by: Ralf Spenneberg <ralf@spenneberg.net>
0c2a2f5
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
0c2a2f5
---
0c2a2f5
 drivers/usb/serial/visor.c | 6 ++++--
0c2a2f5
 1 file changed, 4 insertions(+), 2 deletions(-)
0c2a2f5
0c2a2f5
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
0c2a2f5
index 60afb39eb73c..bbc90c059002 100644
0c2a2f5
--- a/drivers/usb/serial/visor.c
0c2a2f5
+++ b/drivers/usb/serial/visor.c
0c2a2f5
@@ -597,8 +597,10 @@ static int clie_5_attach(struct usb_serial *serial)
0c2a2f5
 	 */
0c2a2f5
 
0c2a2f5
 	/* some sanity check */
0c2a2f5
-	if (serial->num_ports < 2)
0c2a2f5
-		return -1;
0c2a2f5
+	if (serial->num_bulk_out < 2) {
0c2a2f5
+		dev_err(&serial->interface->dev, "missing bulk out endpoints\n");
0c2a2f5
+		return -ENODEV;
0c2a2f5
+	}
0c2a2f5
 
0c2a2f5
 	/* port 0 now uses the modified endpoint Address */
0c2a2f5
 	port = serial->port[0];
0c2a2f5
-- 
0c2a2f5
2.5.0
0c2a2f5