Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: libps2 - fix aborting PS/2 commands

When aborting PS/2 command the kernel should [re]set all flags before
waking up waiters, otherwise waiting thread may read obsolete values
of flags.

Reported-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Link: https://lore.kernel.org/r/20230511185252.386941-6-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+11 -4
+11 -4
drivers/input/serio/libps2.c
··· 478 478 } 479 479 EXPORT_SYMBOL(ps2_handle_response); 480 480 481 + /* 482 + * Clears state of PS/2 device after communication error by resetting majority 483 + * of flags and waking up waiters, if any. 484 + */ 481 485 void ps2_cmd_aborted(struct ps2dev *ps2dev) 482 486 { 483 - if (ps2dev->flags & PS2_FLAG_ACK) 487 + unsigned long old_flags = ps2dev->flags; 488 + 489 + /* reset all flags except last nak */ 490 + ps2dev->flags &= PS2_FLAG_NAK; 491 + 492 + if (old_flags & PS2_FLAG_ACK) 484 493 ps2dev->nak = 1; 485 494 486 - if (ps2dev->flags & (PS2_FLAG_ACK | PS2_FLAG_CMD)) 495 + if (old_flags & (PS2_FLAG_ACK | PS2_FLAG_CMD)) 487 496 wake_up(&ps2dev->wait); 488 497 489 - /* reset all flags except last nack */ 490 - ps2dev->flags &= PS2_FLAG_NAK; 491 498 } 492 499 EXPORT_SYMBOL(ps2_cmd_aborted);