Re: [PATCH 2/2] USB: don't hold usb_bus_list_lock for usb_disconnect()

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

 



On Fri, 13 Sep 2013, Bjorn Helgaas wrote:

> usb_bus_list_lock protects the usb_bus_list, and we don't touch that list
> in usb_disconnect(), so there's no reason to hold the lock here.

The code says:

/* used when updating list of hcds */
DEFINE_MUTEX(usb_bus_list_lock);	/* exported only for usbfs */
EXPORT_SYMBOL_GPL (usb_bus_list_lock);

Unforunately, the first comment is incomplete.  usb_bus_list_lock
protects both the list of buses and also the set of root hubs.  That's
why it isn't needed in hub_quiesce() and hub_port_connect_change();
those routines remove only non-root devices.

Removing the usages in usb_add_hcd() and usb_remove_hcd() isn't safe.  
You can see where this usage is important in
devices.c:usb_device_read().

Ironically, the second comment above is wrong as well.  Although usbfs
does use the lock, usbfs is part of the same module as hcd.c.  
Therefore there's no reason to EXPORT usb_bus_list_lock.

Alan Stern

P.S.: What led you to submit these changes?

--
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