netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: netdev@vger.kernel.org
Cc: linux-usb@vger.kernel.org, "Bjørn Mork" <bjorn@mork.no>,
	"Markus Kolb" <linux-201011@tower-net.de>,
	"Iker Salmón San Millán" <shaola@esdebian.org>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Oliver Neukum" <oliver@neukum.org>,
	655387@bugs.debian.org, stable@vger.kernel.org
Subject: [PATCH net v2] cdc_ether: Ignore bogus union descriptor for RNDIS devices
Date: Thu, 26 Apr 2012 14:35:10 +0200	[thread overview]
Message-ID: <1335443710-2627-1-git-send-email-bjorn@mork.no> (raw)
In-Reply-To: <201204261356.03000.oliver@neukum.org>

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(-)

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,
-- 
1.7.10

  reply	other threads:[~2012-04-26 12:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201204260931.30327.oliver@neukum.org>
2012-04-26 10:55 ` [PATCH net] cdc_ether: Ignore bogus union descriptor for RNDIS devices Bjørn Mork
2012-04-26 11:56   ` Oliver Neukum
2012-04-26 12:35     ` Bjørn Mork [this message]
     [not found]       ` <1335443710-2627-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2012-05-03  1:14         ` [PATCH net v2] " David Miller
     [not found]           ` <20120502.211411.560705499667456177.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-05-03  4:57             ` Markus Kolb
     [not found]               ` <01138af4-69c3-4adb-b7f6-1e5e6f471df2-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2012-05-03  5:11                 ` David Miller
     [not found]                   ` <20120503.011129.639700793389264897.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-05-06 10:13                     ` Markus Kolb
     [not found]                       ` <4FA64ECC.7030005-cHz7HMenPf4hFhg+JK9F0w@public.gmane.org>
2012-05-06 17:12                         ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335443710-2627-1-git-send-email-bjorn@mork.no \
    --to=bjorn@mork.no \
    --cc=655387@bugs.debian.org \
    --cc=jrnieder@gmail.com \
    --cc=linux-201011@tower-net.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=shaola@esdebian.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).