Re: [PATCH] usb: fix deadlock with bandwidth_mutex

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Stern
Date: Tuesday, August 17, 2010 - 7:55 am

On Tue, 17 Aug 2010, Thadeu Lima de Souza Cascardo wrote:


The deadlock problem probably could be handled somehow, but there's a
separate issue: Until the usb_disable_device call finishes unbinding
the drivers, the drivers are free to continue using their allocated
bandwidth.  We musn't change the bandwidth allocations until after the
unbinding is done.  So this patch is indeed necessary.


That's right; we don't have to worry about this case.

Incidentally, you might also want to change the following code at the 
same time:

	mutex_lock(&hcd->bandwidth_mutex);
	ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
	if (ret < 0) {
		usb_autosuspend_device(dev);
		mutex_unlock(&hcd->bandwidth_mutex);
		goto free_interfaces;
	}

In the failure case, it would be safer to drop the mutex _before_
calling usb_autosuspend_device.

Alan Stern

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] usb: fix deadlock with bandwidth_mutex, Alan Stern, (Tue Aug 17, 7:55 am)