linux/drivers/input
Dmitry Torokhov 35f0a0dced Input: ensure device is ready before delivering events
When a device is opened via input_open_device(), the driver's open()
callback is invoked. Some drivers, like cm109, submit URBs or perform
other hardware initialization in their open() callbacks.

However, the input core does not prevent dev->event() from being called
concurrently during the driver's open() execution. For instance, if a
console beep occurs, the kbd handler might inject an EV_SND event. This
can lead to double list_add BUGs if the driver submits the same URB in
both open() and event() paths without adequate synchronization.

To fix this, introduce a ready flag in the input_dev structure.
For complex devices (where dev->open is defined), this flag is set to true
only after the driver's open() method successfully completes. The core now
checks ready in input_event_dispose() and input_dev_toggle()
to prevent events from reaching the hardware before it is fully prepared.
For simple devices (no open callback), events are delivered immediately.

We also replay the logical state in input_open_device() by calling
input_dev_toggle() right after marking the device ready, ensuring no
events are permanently lost.

In the inhibit path, we ensure that physical feedback (LEDs/sounds) is
turned off before the device is closed, and we synchronize the inhibited
state transition under the event lock to prevent races with incoming events.

Assisted-by: Antigravity:gemini-3.5-flash
Link: https://patch.msgid.link/20260803005210.1251102-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2026-08-05 23:01:44 -07:00
..
gameport Input: Drop unused assignments from pnp_device_id arrays 2026-06-10 09:56:01 -07:00
joystick Input: maplecontrol - set driver data before registering input device 2026-07-02 22:49:02 -07:00
keyboard Input: gscps2 - supply PA-RISC keyboard keymap via device property 2026-08-05 22:45:01 -07:00
misc Linux 7.2-rc3 2026-07-13 19:06:00 -07:00
mouse Input: synaptics_i2c - return 0 explicitly on success 2026-08-04 21:27:53 -07:00
rmi4 Input: rmi_smbus - remove conditional return with no effect 2026-08-04 21:27:53 -07:00
serio Input: gscps2 - supply PA-RISC keyboard keymap via device property 2026-08-05 22:45:01 -07:00
tablet Input: remove changelogs 2026-06-10 11:04:17 -07:00
tests Input updates for v6.11-rc0 2024-07-19 16:51:39 -07:00
touchscreen Input: inexio - replace printk with dev_dbg and fix missing space 2026-07-25 18:16:12 -07:00
apm-power.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
evdev.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ff-core.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ff-memless.c Input: stop force-feedback timer when unregistering input devices 2026-06-22 22:33:01 -07:00
input-compat.c Input: move input_bits_to_string() to input-compat.c 2025-08-21 12:00:58 -07:00
input-compat.h Input: move input_bits_to_string() to input-compat.c 2025-08-21 12:00:58 -07:00
input-core-private.h Input: deactivate MT slots when inhibiting or suspending devices 2022-07-20 11:35:13 -07:00
input-leds.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
input-mt.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
input-poller.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
input-poller.h Input: add support for polling to input devices 2019-08-20 12:04:07 -07:00
input.c Input: ensure device is ready before delivering events 2026-08-05 23:01:44 -07:00
joydev.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig Input: remove evbug driver 2024-12-17 13:53:52 -08:00
Makefile Input: touch-overlay - add touchscreen overlay handling 2025-07-27 01:41:21 -07:00
matrix-keymap.c Input: matrix-keymap - switch to using __free() cleanup facility 2024-08-29 10:59:30 -07:00
mousedev.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sparse-keymap.c Input: include export.h in modules using EXPORT_SYMBOL*() 2025-08-21 12:00:59 -07:00
touch-overlay.c Input: include export.h in modules using EXPORT_SYMBOL*() 2025-08-21 12:00:59 -07:00
touchscreen.c Input: include export.h in modules using EXPORT_SYMBOL*() 2025-08-21 12:00:59 -07:00
vivaldi-fmap.c Input: add missing MODULE_DESCRIPTION() macros 2024-06-09 14:38:48 -07:00