a0db662
From 29c6dd591bbd592472247441de9fa694acdabae8 Mon Sep 17 00:00:00 2001
a0db662
From: Oliver Neukum <oneukum@suse.com>
a0db662
Date: Thu, 7 Jan 2016 11:01:00 +0100
a0db662
Subject: [PATCH] cdc-acm: fix NULL pointer reference
a0db662
a0db662
The union descriptor must be checked. Its usage was conditional
a0db662
before the parser was introduced. This is important, because
a0db662
many RNDIS device, which also use the common parser, have
a0db662
bogus extra descriptors.
a0db662
a0db662
Signed-off-by: Oliver Neukum <oneukum@suse.com>
a0db662
Tested-by: Vasily Galkin <galkin-vv@yandex.ru>
a0db662
Signed-off-by: David S. Miller <davem@davemloft.net>
a0db662
---
a0db662
 drivers/net/usb/cdc_ether.c | 8 +++++++-
a0db662
 1 file changed, 7 insertions(+), 1 deletion(-)
a0db662
a0db662
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
a0db662
index 3da70bf..7cba2c3 100644
a0db662
--- a/drivers/net/usb/cdc_ether.c
a0db662
+++ b/drivers/net/usb/cdc_ether.c
a0db662
@@ -160,6 +160,12 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
a0db662
 	info->u = header.usb_cdc_union_desc;
a0db662
 	info->header = header.usb_cdc_header_desc;
a0db662
 	info->ether = header.usb_cdc_ether_desc;
a0db662
+	if (!info->u) {
a0db662
+		if (rndis)
a0db662
+			goto skip;
a0db662
+		else /* in that case a quirk is mandatory */
a0db662
+			goto bad_desc;
a0db662
+	}
a0db662
 	/* we need a master/control interface (what we're
a0db662
 	 * probed with) and a slave/data interface; union
a0db662
 	 * descriptors sort this all out.
a0db662
@@ -256,7 +262,7 @@ skip:
a0db662
 			goto bad_desc;
a0db662
 		}
a0db662
 
a0db662
-	} else if (!info->header || !info->u || (!rndis && !info->ether)) {
a0db662
+	} else if (!info->header || (!rndis && !info->ether)) {
a0db662
 		dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n",
a0db662
 			info->header ? "" : "header ",
a0db662
 			info->u ? "" : "union ",
a0db662
-- 
a0db662
2.5.0
a0db662