usb: gadget: f_mtp: Avoid race between mtp_read and mtp_function_disable lineage-17.1
authorPratham Pratap <prathampratap@codeaurora.org>
Tue, 8 May 2018 10:47:52 +0000 (16:17 +0530)
committerStricted <info@stricted.net>
Tue, 28 Jan 2020 10:51:30 +0000 (10:51 +0000)
commitabd876b3b5fc80dc302183cd372067bab40efab5
tree48d8bf4864b44495295530ae173f3fe4b90b20d2
parent74a6ab25b01d7391ca9ec47efad939358e336fad
usb: gadget: f_mtp: Avoid race between mtp_read and mtp_function_disable

While mtp_read is being executed and mtp_function_disable
is called then all the eps will be disabled which will
lead to NULL pointer dereference in usb_ep_align_maybe
function which will subsequently try to access endpoint
descriptors.
Add spinlock protection in mtp_function_disable to
avoid race between mtp_read and mtp_function_disable.

Change-Id: If7f00ff2a98f75d2782e6bb35ad5fe59e4db6734
Signed-off-by: Pratham Pratap <prathampratap@codeaurora.org>
drivers/usb/gadget/function/f_mtp.c