Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: f_fs: Ensure ep0req is dequeued before free_request

As per the documentation, function usb_ep_free_request guarantees
the request will not be queued or no longer be re-queued (or
otherwise used). However, with the current implementation it
doesn't make sure that the request in ep0 isn't reused.

Fix this by dequeuing the ep0req on functionfs_unbind before
freeing the request to align with the definition.

Fixes: ddf8abd25994 ("USB: f_fs: the FunctionFS driver")
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
Tested-by: Krishna Kurapati <quic_kriskura@quicinc.com>
Link: https://lore.kernel.org/r/20221215052906.8993-3-quic_ugoswami@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Udipto Goswami and committed by
Greg Kroah-Hartman
ce405d56 6a19da11

+2
+2
drivers/usb/gadget/function/f_fs.c
··· 1895 1895 ENTER(); 1896 1896 1897 1897 if (!WARN_ON(!ffs->gadget)) { 1898 + /* dequeue before freeing ep0req */ 1899 + usb_ep_dequeue(ffs->gadget->ep0, ffs->ep0req); 1898 1900 mutex_lock(&ffs->mutex); 1899 1901 usb_ep_free_request(ffs->gadget->ep0, ffs->ep0req); 1900 1902 ffs->ep0req = NULL;