Skip to content

Commit

Permalink
USB: fix interface sysfs file-creation bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Oct 25, 2007
1 parent b22817b commit 439a903
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,13 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
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);
Expand Down

0 comments on commit 439a903

Please sign in to comment.