mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
Kernel/HID: Take a spinlock when calling KeyboardClient::on_key_pressed
The KeyboardClient class member could be updated due to TTY switch, so we must ensure we always use a valid pointer.
This commit is contained in:
parent
b8493bf70f
commit
cd08c4a5aa
Notes:
sideshowbarker
2024-07-17 11:14:26 +09:00
Author: https://github.com/supercomputer7
Commit: cd08c4a5aa
Pull-request: https://github.com/SerenityOS/serenity/pull/13928
Reviewed-by: https://github.com/linusg
3 changed files with 14 additions and 3 deletions
|
@ -254,8 +254,12 @@ void KeyboardDevice::key_state_changed(u8 scan_code, bool pressed)
|
|||
|
||||
if (pressed)
|
||||
event.flags |= Is_Press;
|
||||
if (HIDManagement::the().m_client)
|
||||
HIDManagement::the().m_client->on_key_pressed(event);
|
||||
|
||||
{
|
||||
SpinlockLocker locker(HIDManagement::the().m_client_lock);
|
||||
if (HIDManagement::the().m_client)
|
||||
HIDManagement::the().m_client->on_key_pressed(event);
|
||||
}
|
||||
|
||||
{
|
||||
SpinlockLocker lock(m_queue_lock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue