|
@@ -2598,26 +2598,23 @@ EXPORT_SYMBOL_GPL(usb_create_hcd);
|
|
|
* Don't deallocate the bandwidth_mutex until the last shared usb_hcd is
|
|
|
* deallocated.
|
|
|
*
|
|
|
- * Make sure to only deallocate the bandwidth_mutex when the primary HCD is
|
|
|
- * freed. When hcd_release() is called for either hcd in a peer set
|
|
|
- * invalidate the peer's ->shared_hcd and ->primary_hcd pointers to
|
|
|
- * block new peering attempts
|
|
|
+ * Make sure to deallocate the bandwidth_mutex only when the last HCD is
|
|
|
+ * freed. When hcd_release() is called for either hcd in a peer set,
|
|
|
+ * invalidate the peer's ->shared_hcd and ->primary_hcd pointers.
|
|
|
*/
|
|
|
static void hcd_release(struct kref *kref)
|
|
|
{
|
|
|
struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
|
|
|
|
|
|
mutex_lock(&usb_port_peer_mutex);
|
|
|
- if (usb_hcd_is_primary_hcd(hcd)) {
|
|
|
- kfree(hcd->address0_mutex);
|
|
|
- kfree(hcd->bandwidth_mutex);
|
|
|
- }
|
|
|
if (hcd->shared_hcd) {
|
|
|
struct usb_hcd *peer = hcd->shared_hcd;
|
|
|
|
|
|
peer->shared_hcd = NULL;
|
|
|
- if (peer->primary_hcd == hcd)
|
|
|
- peer->primary_hcd = NULL;
|
|
|
+ peer->primary_hcd = NULL;
|
|
|
+ } else {
|
|
|
+ kfree(hcd->address0_mutex);
|
|
|
+ kfree(hcd->bandwidth_mutex);
|
|
|
}
|
|
|
mutex_unlock(&usb_port_peer_mutex);
|
|
|
kfree(hcd);
|