usb: gadget: f_mtp: Avoid race between mtp_read and mtp_function_disable
authorPratham Pratap <prathampratap@codeaurora.org>
Tue, 8 May 2018 10:47:52 +0000 (16:17 +0530)
committerivanmeler <i_ivan@windowslive.com>
Wed, 13 Apr 2022 21:14:03 +0000 (21:14 +0000)
commita0da834c602e55942b9866b1340807f57eaeccd0
treed1d01fabb8856655de41aec9c411f0fbd8d701af
parent561289b9772ba9cca05b37fd8217a78eeab99fd4
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