Re: [PATCH] USB: xhci - also free streams when resetting devices

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

 



On Tue, Apr 12, 2011 at 11:06:28PM -0700, Dmitry Torokhov wrote:
> Currently, when resetting a device, xHCI driver disables all but one
> endpoints and frees their rings, but leaves alone any streams that
> might have been allocated. Later, when users try to free allocated
> streams, we oops in xhci_setup_no_streams_ep_input_ctx() because
> ep->ring is NULL.
> 
> Let's free not only rings but also stream data as well, so that
> calling free_streams() on a device that was reset will be safe.

Thanks for catching this.  I think Matthew Wilcox sent me a similar
patch months ago and it got lost in my inbox somewhere. :(  I'll queue
this as soon as I get the other USB 3.0 hub fixes settled.

Sarah Sharp

> Reviewed-by: Micah Elizabeth Scott <micah@xxxxxxxxxx>
> Signed-off-by: Dmitry Torokhov <dtor@xxxxxxxxxx>
> ---
> 
>  drivers/usb/host/xhci.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 196e018..48706c0 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -2386,10 +2386,18 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
>  	/* Everything but endpoint 0 is disabled, so free or cache the rings. */
>  	last_freed_endpoint = 1;
>  	for (i = 1; i < 31; ++i) {
> -		if (!virt_dev->eps[i].ring)
> -			continue;
> -		xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
> -		last_freed_endpoint = i;
> +		struct xhci_virt_ep *ep = &virt_dev->eps[i];
> +
> +		if (ep->ep_state & EP_HAS_STREAMS) {
> +			xhci_free_stream_info(xhci, ep->stream_info);
> +			ep->stream_info = NULL;
> +			ep->ep_state &= ~EP_HAS_STREAMS;
> +		}
> +
> +		if (ep->ring) {
> +			xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i);
> +			last_freed_endpoint = i;
> +		}
>  	}
>  	xhci_dbg(xhci, "Output context after successful reset device cmd:\n");
>  	xhci_dbg_ctx(xhci, virt_dev->out_ctx, last_freed_endpoint);
> -- 
> 1.7.4.1
> 
--
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