]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
usb: gadget: f_fs: Ensure io_completion_wq is idle during unbind
authorWesley Cheng <wcheng@codeaurora.org>
Sat, 22 May 2021 00:44:21 +0000 (17:44 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 15 Jul 2021 17:24:05 +0000 (19:24 +0200)
commit230b363b7819c5a2b32f17a289959fefc0730fef
treeb5588013cc5bbade849d4aafebfa950bb87435b8
parent67b2db558a49c9eac89f6e1714338a39dc732b96
usb: gadget: f_fs: Ensure io_completion_wq is idle during unbind

BugLink: https://bugs.launchpad.net/bugs/1934012
commit 6fc1db5e6211e30fbb1cee8d7925d79d4ed2ae14 upstream.

During unbind, ffs_func_eps_disable() will be executed, resulting in
completion callbacks for any pending USB requests.  When using AIO,
irrespective of the completion status, io_data work is queued to
io_completion_wq to evaluate and handle the completed requests.  Since
work runs asynchronously to the unbind() routine, there can be a
scenario where the work runs after the USB gadget has been fully
removed, resulting in accessing of a resource which has been already
freed. (i.e. usb_ep_free_request() accessing the USB ep structure)

Explicitly drain the io_completion_wq, instead of relying on the
destroy_workqueue() (in ffs_data_put()) to make sure no pending
completion work items are running.

Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1621644261-1236-1-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/usb/gadget/function/f_fs.c