]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
usb: gadget: u_audio: fix race condition on endpoint stop
authorJerome Brunet <jbrunet@baylibre.com>
Fri, 27 Aug 2021 09:29:27 +0000 (11:29 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 24 Sep 2021 09:58:34 +0000 (11:58 +0200)
commit14b5421c67476ac93b59bcf0b304b1bac0cb3e9d
tree08544e9d3feebbd62296340e165cbe4df739417c
parent5ff3d5fcd035e3357d67f334180108679c1b029b
usb: gadget: u_audio: fix race condition on endpoint stop

BugLink: https://bugs.launchpad.net/bugs/1944610
[ Upstream commit 068fdad20454f815e61e6f6eb9f051a8b3120e88 ]

If the endpoint completion callback is call right after the ep_enabled flag
is cleared and before usb_ep_dequeue() is call, we could do a double free
on the request and the associated buffer.

Fix this by clearing ep_enabled after all the endpoint requests have been
dequeued.

Fixes: 7de8681be2cd ("usb: gadget: u_audio: Free requests only after callback")
Cc: stable <stable@vger.kernel.org>
Reported-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20210827092927.366482-1-jbrunet@baylibre.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/usb/gadget/function/u_audio.c