OSDN Git Service

ANDROID: keychord: Fix races in keychord_write.
authorMohan Srinivasan <srmohan@google.com>
Wed, 9 Aug 2017 19:16:56 +0000 (12:16 -0700)
committerMohan Srinivasan <srmohan@google.com>
Fri, 11 Aug 2017 19:40:11 +0000 (19:40 +0000)
commit462acca2816ee795fde81bdd99ca6e10bfe00d27
tree0f8267220d14f0c5a6b19aa86a9530c79161fd63
parentdd5826152c53c1ea77986c1f3d99050d538e65e3
ANDROID: keychord: Fix races in keychord_write.

There are multiple bugs caused by threads racing in keychord_write.
1) Threads racing through this function can cause the same element to
be added to a linked list twice (multiple calls to
input_register_handler() for the same input_handler struct). And the
races can also cause an element in a linked list that doesn't exist
attempted to be removed (multiple calls to input_unregister_handler()
with the same input_handler struct).
2) The races can also cause duplicate kfree's of the keychords
struct.

Bug: 64133562
Bug: 63974334
Change-Id: I6329a4d58c665fab5d3e96ef96391e07b4941e80
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
(cherry picked from commit 59584701f1e2ce8ce024570576b206bea6ac69cf)
drivers/input/misc/keychord.c