USB: gadget: f_hid: fix deadlock in f_hidg_write()
Quoted 15 lines · Radoslav Gerganov
In
f_hidg_write()thewrite_spinlockis acquired before callingusb_ep_queue()which causes a deadlock whendummy_hcdis being used. This is becausedummy_queue()callbacks intof_hidg_req_complete()which tries to acquire the same spinlock. This is (part of) the backtrace when the deadlock occurs:
0xffffffffc06b1410inf_hidg_req_complete0xffffffffc06a590ainusb_gadget_giveback_request0xffffffffc06cfff2indummy_queue0xffffffffc06a4b96inusb_ep_queue0xffffffffc06b1eb6inf_hidg_write0xffffffff8127730bin__vfs_write0xffffffff812774d1invfs_write0xffffffff81277725inSYSC_write
Quoted 2 lines
Fix this by releasing the
write_spinlockbefore callingusb_ep_queue()
This fixes a usb_f_hid deadlock I've also been seeing with a FIDO key emulator. This is a serious bug in that it brings down my entire system if I use the hid gadget in any way, so can we please get it applied? It turns out to have been introduced by this commit:
commit 749494b6bdbbaf0899aa1c62a1ad74cd747bce47
Author: Krzysztof Opasiak <[email protected]> Date: Tue Jan 24 03:27:24 2017 +0100
usb: gadget: f_hid: fix: Move IN request allocation to set_alt()
So you can add
James