6204283
From f7a3aa353011e38e119adebd845b38551587a26a Mon Sep 17 00:00:00 2001
6204283
From: Oliver Neukum <oneukum@suse.com>
6204283
Date: Thu, 17 Mar 2016 16:25:33 +0100
6204283
Subject: [PATCH] cypress_m8: add sanity checking
6204283
6204283
An attack using missing endpoints exists.
6204283
CVE-2016-3137
6204283
6204283
Signed-off-by: Oliver Neukum <ONeukum@suse.com>
6204283
CC: stable@vger.kernel.org
6204283
6204283
v1 - add sanity check
6204283
v2 - add error logging
6204283
v3 - correct error message
6204283
---
6204283
 drivers/usb/serial/cypress_m8.c | 11 +++++------
6204283
 1 file changed, 5 insertions(+), 6 deletions(-)
6204283
6204283
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
6204283
index 01bf53392819..5e25443fe4ef 100644
6204283
--- a/drivers/usb/serial/cypress_m8.c
6204283
+++ b/drivers/usb/serial/cypress_m8.c
6204283
@@ -447,6 +447,11 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)
6204283
 	struct usb_serial *serial = port->serial;
6204283
 	struct cypress_private *priv;
6204283
 
6204283
+	if (!port->interrupt_out_urb || !port->interrupt_in_urb) {
6204283
+		dev_err(&port->dev, "A required endpoint is missing\n");
6204283
+		return -ENODEV;
6204283
+	}
6204283
+
6204283
 	priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
6204283
 	if (!priv)
6204283
 		return -ENOMEM;
6204283
@@ -606,12 +611,6 @@ static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
6204283
 		cypress_set_termios(tty, port, &priv->tmp_termios);
6204283
 
6204283
 	/* setup the port and start reading from the device */
6204283
-	if (!port->interrupt_in_urb) {
6204283
-		dev_err(&port->dev, "%s - interrupt_in_urb is empty!\n",
6204283
-			__func__);
6204283
-		return -1;
6204283
-	}
6204283
-
6204283
 	usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
6204283
 		usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
6204283
 		port->interrupt_in_urb->transfer_buffer,
6204283
-- 
6204283
2.5.0
6204283