Re: [PATCH] usb/g_zero: don't access private data in complete callback on error

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

 



On Mon, 23 Jan 2012, Sebastian Andrzej Siewior wrote:

> The following scenario:
> - use a third party tool
> - issue SetConfiguration, start a transfer
> - g_zero enqueues 4k reqs. Be rude and stop after a multiple of maxpacketsize
>   but before the 4k
> - Assume the UDC can handle 4k transfer in one go and will interrupt after the
>   4k arrived or a short transfer. That the transfer is still "busy".
> - now soft the disconnect the device.
> - the UDC gets a SetConfiguration 0 and will disable all endpoints
> - disabling an endpoint means cancles all pending transfers.
> 
> On DWC3 we issue a cancel transfer command and wait for the command/transfer to
> complete.

Do you mean you _don't_ wait for the transfer to complete?

>  That means we return immediately from ->disable(). The _gadget_ has to
> wait for the ->complete() callback. g_zero does not and the result is:

This patch is wrong; DWC3 must be fixed instead.  From 
include/linux/usb/gadget.h:

/**
 * usb_ep_disable - endpoint is no longer usable
 * @ep:the endpoint being unconfigured.  may not be the endpoint named "ep0".
 *
 * no other task may be using this endpoint when this is called.
 * any pending and uncompleted requests will complete with status
 * indicating disconnect (-ESHUTDOWN) before this call returns.
 * gadget drivers must call usb_ep_enable() again before queueing
 * requests to the endpoint.
 *
 * returns zero, or a negative error code.
 */

Alan Stern

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