USB: gadget: f_mass_storage: Fix race condition using proper locking
fsg_common_free_luns() API is called from fsg_unbind() context when
composition switch or adbd is being killed which releases configured
LUNs (i.e. common->luns). common->luns are also being updated from
handle_exception() context when fsg_disable() invokes exception with
FSG_STATE_CONFIG_CHANGE value. In some cases it is observed that
common->luns are being updated from fsg_common_free_luns() when it is
already being used from handle_exception context. Hence fix this issue
by acquiring common->lock before freeing LUNs.
Also set common->nluns to zero after releaseing all LUNs.
CRs-Fixed: 863034
Change-Id: Iad26fe288f382e4d0b0e257aae348f6d80b45035
Signed-off-by:
Mayank Rana <mrana@codeaurora.org>
Loading
Please register or sign in to comment