summaryrefslogtreecommitdiff
path: root/kernel/locking/mutex-debug.c
diff options
context:
space:
mode:
authorRoderick Colenbrander <roderick@gaikai.com>2019-08-02 14:27:28 -0700
committerSiarhei Vishniakou <svv@google.com>2019-11-08 10:13:16 -0600
commit2a0af931638da37736975f6ad649c5297a3f18f5 (patch)
treee6cfe85c2e77f806a48c8939556e4767bcf88969 /kernel/locking/mutex-debug.c
parent64aecec953d7778fb704ba5c476f3694b1fb66eb (diff)
UPSTREAM: HID: sony: Fix race condition between rumble and device remove.
Valve reported a kernel crash on Ubuntu 18.04 when disconnecting a DS4 gamepad while rumble is enabled. This issue is reproducible with a frequency of 1 in 3 times in the game Borderlands 2 when using an automatic weapon, which triggers many rumble operations. We found the issue to be a race condition between sony_remove and the final device destruction by the HID / input system. The problem was that sony_remove didn't clean some of its work_item state in "struct sony_sc". After sony_remove work, the corresponding evdev node was around for sufficient time for applications to still queue rumble work after "sony_remove". On pre-4.19 kernels the race condition caused a kernel crash due to a NULL-pointer dereference as "sc->output_report_dmabuf" got freed during sony_remove. On newer kernels this crash doesn't happen due the buffer now being allocated using devm_kzalloc. However we can still queue work, while the driver is an undefined state. This patch fixes the described problem, by guarding the work_item "state_worker" with an initialized variable, which we are setting back to 0 on cleanup. Bug: 139372370 Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> CC: stable@vger.kernel.org (cherry picked from commit e0f6974a54d3f7f1b5fdf5a593bd43ce9206ec04 ("HID: sony: Fix race condition between rumble and device remove.")) Signed-off-by: Siarhei Vishniakou <svv@google.com> Change-Id: I08ba1daf2d539f4089b5098cff7b9bc2be2f1645
Diffstat (limited to 'kernel/locking/mutex-debug.c')
0 files changed, 0 insertions, 0 deletions