]> err.no Git - linux-2.6/commitdiff
USB: fix interface sysfs file-creation bug
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 19 Oct 2007 13:51:58 +0000 (09:51 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 25 Oct 2007 19:18:44 +0000 (12:18 -0700)
This patch (as1005) fixes a rather subtle problem.  When
usb_set_configuration() registers the interfaces and their files in
sysfs, it doesn't expect those files to exist already.  But when an
interface is registered, its driver may call usb_set_interface() and
thereby cause the sysfs files to be created.  The result is an error
when usb_set_configuration() goes on to create those same files again.

The (not-so-great) solution is to have usb_set_configuration() remove
any existing files before creating them.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/message.c

index 8bdaa157ffe7dd7a6fe1276ef2a26544742e7197..eb4ac47612a59022878b19e4da34053fdd4cbb6f 100644 (file)
@@ -1641,7 +1641,13 @@ free_interfaces:
                                intf->dev.bus_id, ret);
                        continue;
                }
-               usb_create_sysfs_intf_files (intf);
+
+               /* The driver's probe method can call usb_set_interface(),
+                * which would mean the interface's sysfs files are already
+                * created.  Just in case, we'll remove them first.
+                */
+               usb_remove_sysfs_intf_files(intf);
+               usb_create_sysfs_intf_files(intf);
        }
 
        usb_autosuspend_device(dev);