> > At a quick glance, I suspect the more correct fix is to make
> > the "goto out1;" after init fails be a "goto out3;" ...
> >
> > - Dave
> >
> >
> 
> Nah.  We shouldn't need to call unbind() if bind() fails.

True, but we SHOULD do that if a fault shows up after it succeeds...
unlikely though that is.  (See appended patch.)


> Nov 28 08:16:16 ameeba kernel: rndis_host 1-3.6:1.14: RNDIS init failed, -32
> Nov 28 08:16:16 ameeba kernel: usb%d: unregister 'rndis_host'
> usb-0000:00:02.1-3.6, RNDIS device
> 
> It turns out that disconnect() was being called from
> drivers/usb/net/rndis_host.c
> 414                 dev_err(&intf->dev, "RNDIS init failed, %d\n", retval);
> 415 fail:
> 416                 usb_driver_release_interface(driver_of(intf),
> 417                         ((struct cdc_state *)&(dev->data))->data);
> 
> According to the comments on usb_driver_release_interface() it
> normally calls disconnect and then the probe frees net again in the
> error path...
> 
> Probably I can remove the call to usb_driver_release_interface() and
> submit a patch?

Maybe, but better would be to do what generic_cdc_bind() does when it
cleans up ... the reason release_interface() is called there is to
ensure that when some other driver tries to bind to that device's
interfaces, everything works correctly.  This is the probe() path,
and there'd normally be no reason to release that interface short
of a device unplug.

- Dave


This cleans up some unlikely error handling paths in usbnet device probing.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>

Index: g26/drivers/usb/net/usbnet.c
===================================================================
--- g26.orig/drivers/usb/net/usbnet.c   2006-12-13 12:32:15.000000000 -0800
+++ g26/drivers/usb/net/usbnet.c        2006-12-13 12:32:17.000000000 -0800
@@ -1182,6 +1182,9 @@ usbnet_probe (struct usb_interface *udev
        // NOTE net->name still not usable ...
        if (info->bind) {
                status = info->bind (dev, udev);
+               if (status < 0)
+                       goto out1;
+
                // heuristic:  "usb%d" for links we know are two-host,
                // else "eth%d" when there's reasonable doubt.  userspace
                // can rename the link if it knows better.
@@ -1208,12 +1211,12 @@ usbnet_probe (struct usb_interface *udev
        if (status == 0 && dev->status)
                status = init_status (dev, udev);
        if (status < 0)
-               goto out1;
+               goto out3;
 
        if (!dev->rx_urb_size)
                dev->rx_urb_size = dev->hard_mtu;
        dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
-       
+
        SET_NETDEV_DEV(net, &udev->dev);
        status = register_netdev (net);
        if (status)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to