usb: gadget: f_fs: Fix use after free issue as part of queue failure
authorSriharsha Allenki <sallenki@codeaurora.org>
Thu, 26 Mar 2020 11:56:20 +0000 (17:26 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 06:00:33 +0000 (08:00 +0200)
commit03ee78583a9e1a7e52819a2f95ef6c9f70397dbb
tree90d23adf0c0836737aca111d3d550f198dcb2162
parentbdf7505f814a6aaea188a3c075979be36ee35c59
usb: gadget: f_fs: Fix use after free issue as part of queue failure

commit f63ec55ff904b2f2e126884fcad93175f16ab4bb upstream.

In AIO case, the request is freed up if ep_queue fails.
However, io_data->req still has the reference to this freed
request. In the case of this failure if there is aio_cancel
call on this io_data it will lead to an invalid dequeue
operation and a potential use after free issue.
Fix this by setting the io_data->req to NULL when the request
is freed as part of queue failure.

Fixes: 2e4c7553cd6f ("usb: gadget: f_fs: add aio support")
Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
CC: stable <stable@vger.kernel.org>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Link: https://lore.kernel.org/r/20200326115620.12571-1-sallenki@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c