usb: gadget: f_fs: Fix use-after-free
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 14 Apr 2016 15:01:17 +0000 (17:01 +0200)
committerSasha Levin <sasha.levin@oracle.com>
Tue, 10 May 2016 16:17:31 +0000 (12:17 -0400)
commit0763ce11708553fc7b2124f184ce2e4bb0cb186d
tree9fdfb232dd1092f4bfb17c87276b773cbfe8e660
parent18e7c4b1a1b62cacc92e2373a14db6d1d177712a
usb: gadget: f_fs: Fix use-after-free

[ Upstream commit 38740a5b87d53ceb89eb2c970150f6e94e00373a ]

When using asynchronous read or write operations on the USB endpoints the
issuer of the IO request is notified by calling the ki_complete() callback
of the submitted kiocb when the URB has been completed.

Calling this ki_complete() callback will free kiocb. Make sure that the
structure is no longer accessed beyond that point, otherwise undefined
behaviour might occur.

Fixes: 2e4c7553cd6f ("usb: gadget: f_fs: add aio support")
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/usb/gadget/function/f_fs.c