]> git.baikalelectronics.ru Git - kernel.git/commit
usb: gadget: f_fs: change ep->ep safe in ffs_epfile_io()
authorLinyu Yuan <quic_linyyuan@quicinc.com>
Fri, 10 Jun 2022 12:17:58 +0000 (20:17 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2022 12:45:38 +0000 (14:45 +0200)
commita34e1cee1a7e78eee19d7ebe3033657d9368baba
tree87efea097e0d86828199fdd44ee9bbb4e89d440a
parent54a816572988685080fa62db41eab8c303f6a0eb
usb: gadget: f_fs: change ep->ep safe in ffs_epfile_io()

In ffs_epfile_io(), when read/write data in blocking mode, it will wait
the completion in interruptible mode, if task receive a signal, it will
terminate the wait, at same time, if function unbind occurs,
ffs_func_unbind() will kfree all eps, ffs_epfile_io() still try to
dequeue request by dereferencing ep which may become invalid.

Fix it by add ep spinlock and will not dereference ep if it is not valid.

Cc: <stable@vger.kernel.org> # 5.15
Reported-by: Michael Wu <michael@allwinnertech.com>
Tested-by: Michael Wu <michael@allwinnertech.com>
Reviewed-by: John Keeping <john@metanate.com>
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/1654863478-26228-3-git-send-email-quic_linyyuan@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_fs.c