From: Alan Stern Date: Fri, 29 Jul 2005 19:17:16 +0000 (-0700) Subject: [PATCH] USB: Usbcore: Don't try to delete unregistered interfaces X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=86d30741e480f40676c2173e1153368a4846da48;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [PATCH] USB: Usbcore: Don't try to delete unregistered interfaces This patch handles a rarely-encountered failure mode in usbcore. It's legal for device_add to fail (although now it happens even more rarely than before since failure to bind a driver is no longer fatal). So when we destroy the interfaces in a configuration, we shouldn't try to delete ones which weren't successfully registered. Also, failure to register an interface shouldn't be fatal either -- I think; you may disagree about this part of the patch. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index a428ef479bd7..88d1b376f67c 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -985,8 +985,10 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface; - /* remove this interface */ + /* remove this interface if it has been registered */ interface = dev->actconfig->interface[i]; + if (!klist_node_attached(&interface->dev.knode_bus)) + continue; dev_dbg (&dev->dev, "unregistering interface %s\n", interface->dev.bus_id); usb_remove_sysfs_intf_files(interface); @@ -1439,7 +1441,7 @@ free_interfaces: } } - return ret; + return 0; } // synchronous request completion model