aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2013-11-01 06:16:48 -0400
committerDavid S. Miller <davem@davemloft.net>2013-11-02 02:02:03 -0400
commit9fe0234c0bf8b3c412df0adc9ebbe6a1e95daf51 (patch)
tree79765bbde90b2353bf1942ce9f1c2fb6111d0f86 /drivers/net/usb
parent832922362e1308aaef95a43383577d56f51fbc3c (diff)
net: cdc_ncm: only the control intf can be probed
The probed interface must be the master/control interface of the function. Make this explicit and simplify redundant tests. Cc: Alexey Orishko <alexey.orishko@gmail.com> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/cdc_ncm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 435fcc75d706..5aa3e60851d0 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -394,6 +394,9 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
394 /* store ctx pointer in device data field */ 394 /* store ctx pointer in device data field */
395 dev->data[0] = (unsigned long)ctx; 395 dev->data[0] = (unsigned long)ctx;
396 396
397 /* only the control interface can be successfully probed */
398 ctx->control = intf;
399
397 /* get some pointers */ 400 /* get some pointers */
398 driver = driver_of(intf); 401 driver = driver_of(intf);
399 buf = intf->cur_altsetting->extra; 402 buf = intf->cur_altsetting->extra;
@@ -411,9 +414,10 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
411 break; 414 break;
412 415
413 union_desc = (const struct usb_cdc_union_desc *)buf; 416 union_desc = (const struct usb_cdc_union_desc *)buf;
414 417 /* the master must be the interface we are probing */
415 ctx->control = usb_ifnum_to_if(dev->udev, 418 if (intf->cur_altsetting->desc.bInterfaceNumber !=
416 union_desc->bMasterInterface0); 419 union_desc->bMasterInterface0)
420 goto error;
417 ctx->data = usb_ifnum_to_if(dev->udev, 421 ctx->data = usb_ifnum_to_if(dev->udev,
418 union_desc->bSlaveInterface0); 422 union_desc->bSlaveInterface0);
419 break; 423 break;
@@ -459,14 +463,12 @@ advance:
459 463
460 /* some buggy devices have an IAD but no CDC Union */ 464 /* some buggy devices have an IAD but no CDC Union */
461 if (!union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) { 465 if (!union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
462 ctx->control = intf;
463 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1); 466 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
464 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n"); 467 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
465 } 468 }
466 469
467 /* check if we got everything */ 470 /* check if we got everything */
468 if ((ctx->control == NULL) || (ctx->data == NULL) || 471 if (!ctx->data || (!ctx->mbim_desc && !ctx->ether_desc))
469 ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
470 goto error; 472 goto error;
471 473
472 /* claim data interface, if different from control */ 474 /* claim data interface, if different from control */