re: cdc-ether: switch to common CDC parser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Oliver Neukum,

The patch 823bd3433424: "cdc-ether: switch to common CDC parser" from
Sep 7, 2015, leads to the following static checker warning:

	drivers/net/usb/cdc_ether.c:248 usbnet_generic_cdc_bind()
	warn: variable dereferenced before check 'info->u' (see line 168)

drivers/net/usb/cdc_ether.c
   160          info->u = header.usb_cdc_union_desc;

Assigned.

   161          info->header = header.usb_cdc_header_desc;
   162          info->ether = header.usb_cdc_ether_desc;
   163          /* we need a master/control interface (what we're
   164           * probed with) and a slave/data interface; union
   165           * descriptors sort this all out.
   166           */
   167          info->control = usb_ifnum_to_if(dev->udev,
   168          info->u->bMasterInterface0);

Patch adds dereference outside the check for NULL.  And confusing
indenting as well.

   169          info->data = usb_ifnum_to_if(dev->udev,
   170                  info->u->bSlaveInterface0);
   171          if (!info->control || !info->data) {
   172                  dev_dbg(&intf->dev,
   173                          "master #%u/%p slave #%u/%p\n",

[ snip ] 

   240          /* Microsoft ActiveSync based and some regular RNDIS devices lack the
   241           * CDC descriptors, so we'll hard-wire the interfaces and not check
   242           * for descriptors.
   243           *
   244           * Some Android RNDIS devices have a CDC Union descriptor pointing
   245           * to non-existing interfaces.  Ignore that and attempt the same
   246           * hard-wired 0 and 1 interfaces.
   247           */
   248          if (rndis && (!info->u || android_rndis_quirk)) {
                               ^^^^^^^
This check for NULL is too late.

   249                  info->control = usb_ifnum_to_if(dev->udev, 0);
   250                  info->data = usb_ifnum_to_if(dev->udev, 1);
   251                  if (!info->control || !info->data || info->control != intf) {
   252                          dev_dbg(&intf->dev,
   253                                  "rndis: master #0/%p slave #1/%p\n",
   254                                  info->control,
   255                                  info->data);
   256                          goto bad_desc;
   257                  }
   258  
   259          } else if (!info->header || !info->u || (!rndis && !info->ether)) {


regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux