diff mbox

[net,v2] cdc_ether: Ignore bogus union descriptor for RNDIS devices

Message ID 1335443710-2627-1-git-send-email-bjorn@mork.no
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Bjørn Mork April 26, 2012, 12:35 p.m. UTC
Some RNDIS devices include a bogus CDC Union descriptor pointing
to non-existing interfaces.  The RNDIS code is already prepared
to handle devices without a CDC Union descriptor by hardwiring
the driver to use interfaces 0 and 1, which is correct for the
devices with the bogus descriptor as well. So we can reuse the
existing workaround.

Cc: Markus Kolb <linux-201011@tower-net.de>
Cc: Iker Salmón San Millán <shaola@esdebian.org>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: 655387@bugs.debian.org
Cc: stable@vger.kernel.org
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
v2: adding a test to verify that the resulting control interface is the
    probed interface, as suggested by Oliver Neukum

The same comments as for v1 regarding testing applies.  This is build
tested only.  Should go through some functional testing before being
applied.


Bjørn

 drivers/net/usb/cdc_ether.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

David Miller May 3, 2012, 1:14 a.m. UTC | #1
From: Bjørn Mork <bjorn@mork.no>
Date: Thu, 26 Apr 2012 14:35:10 +0200

> The same comments as for v1 regarding testing applies.  This is build
> tested only.  Should go through some functional testing before being
> applied.

Well?  Is anyone gonna test this?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Kolb May 3, 2012, 4:57 a.m. UTC | #2
David Miller <davem@davemloft.net> schrieb:

>From: Bjørn Mork <bjorn@mork.no>
>Date: Thu, 26 Apr 2012 14:35:10 +0200
>
>> The same comments as for v1 regarding testing applies.  This is build
>> tested only.  Should go through some functional testing before being
>> applied.
>
>Well?  Is anyone gonna test this?

I'll build it during next rainy day and will report its success after some usage ;-)

Markus
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 3, 2012, 5:11 a.m. UTC | #3
From: Markus Kolb <linux-201011@tower-net.de>
Date: Thu, 03 May 2012 06:57:39 +0200

> I'll build it during next rainy day and will report its success
> after some usage ;-)

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Kolb May 6, 2012, 10:13 a.m. UTC | #4
David Miller wrote on 03.05.2012 07:11:
> From: Markus Kolb<linux-201011@tower-net.de>
> Date: Thu, 03 May 2012 06:57:39 +0200
>
>> I'll build it during next rainy day and will report its success
>> after some usage ;-)
>
> Thank you.

Works without any problem for me.
So maybe this patch will be included in the official kernels before I'll 
buy a new mobile phone?! ;-)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 6, 2012, 5:12 p.m. UTC | #5
From: Markus Kolb <markus@kolbs-net.de>
Date: Sun, 06 May 2012 12:13:32 +0200

> David Miller wrote on 03.05.2012 07:11:
>> From: Markus Kolb<linux-201011@tower-net.de>
>> Date: Thu, 03 May 2012 06:57:39 +0200
>>
>>> I'll build it during next rainy day and will report its success
>>> after some usage ;-)
>>
>> Thank you.
> 
> Works without any problem for me.
> So maybe this patch will be included in the official kernels before
> I'll buy a new mobile phone?! ;-)

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 90a3002..00880ed 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -83,6 +83,7 @@  int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 	struct cdc_state		*info = (void *) &dev->data;
 	int				status;
 	int				rndis;
+	bool				android_rndis_quirk = false;
 	struct usb_driver		*driver = driver_of(intf);
 	struct usb_cdc_mdlm_desc	*desc = NULL;
 	struct usb_cdc_mdlm_detail_desc *detail = NULL;
@@ -195,6 +196,11 @@  int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 					info->control,
 					info->u->bSlaveInterface0,
 					info->data);
+				/* fall back to hard-wiring for RNDIS */
+				if (rndis) {
+					android_rndis_quirk = true;
+					goto next_desc;
+				}
 				goto bad_desc;
 			}
 			if (info->control != intf) {
@@ -271,11 +277,15 @@  next_desc:
 	/* Microsoft ActiveSync based and some regular RNDIS devices lack the
 	 * CDC descriptors, so we'll hard-wire the interfaces and not check
 	 * for descriptors.
+	 *
+	 * Some Android RNDIS devices have a CDC Union descriptor pointing
+	 * to non-existing interfaces.  Ignore that and attempt the same
+	 * hard-wired 0 and 1 interfaces.
 	 */
-	if (rndis && !info->u) {
+	if (rndis && (!info->u || android_rndis_quirk)) {
 		info->control = usb_ifnum_to_if(dev->udev, 0);
 		info->data = usb_ifnum_to_if(dev->udev, 1);
-		if (!info->control || !info->data) {
+		if (!info->control || !info->data || info->control != intf) {
 			dev_dbg(&intf->dev,
 				"rndis: master #0/%p slave #1/%p\n",
 				info->control,