Input: always accept EV_SYN in input_event()
Subsystems (2)
Dmitry Torokhov
maintainerPATCH 1/1 Input: always accept EV_SYN in input_event()
Commit 0cd587735205 ("Input: preallocate memory to hold event values") moved allocation of dev->vals into input_allocate_device(), which caused input core to accumulate events reported while seeding initial device state before input_register_device().
However, because EV_SYN is only set in dev->evbit during input_register_device() (and some drivers also overwrite dev->evbit directly before registration), any EV_SYN/SYN_REPORT events sent before registration were dropped by is_event_supported(), leaving those seeded events stuck in dev->vals until the next SYN_REPORT after registration.
Always accept EV_SYN in input_event() and input_inject_event() without checking dev->evbit so input_sync() flushes dev->vals as intended.
--- drivers/input/input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/input.c +2 -2
@@ -452,7 +452,7 @@ void input_handle_event(struct input_dev *dev,void input_event (struct input_dev *dev,unsigned int type,unsigned int code,int value) { -if (is_event_supported (type, dev->evbit,EV_MAX )) { +if (type ==EV_SYN ||is_event_supported (type, dev->evbit,EV_MAX )) {guard (spinlock_irqsave)(&dev->event_lock);input_handle_event (dev, type, code, value); }
@@ -476,7 +476,7 @@ void input_inject_event(struct input_handle *handle,struct input_dev *dev = handle->dev;struct input_handle *grab; -if (is_event_supported (type, dev->evbit,EV_MAX )) { +if (type ==EV_SYN ||is_event_supported (type, dev->evbit,EV_MAX )) {guard (spinlock_irqsave)(&dev->event_lock);guard (rcu)();
Signature · 5 lines
2.56.0.385.gd3acb90ef8-goog -- Dmitry
Quoted 11 lines · Dmitry Torokhov
Commit
0cd587735205("Input: preallocate memory to hold event values") moved allocation ofdev->valsintoinput_allocate_device(), which caused input core to accumulate events reported while seeding initial device state beforeinput_register_device().However, because
EV_SYNis only set indev->evbitduringinput_register_device()(and some drivers also overwritedev->evbitdirectly before registration), any EV_SYN/SYN_REPORT events sent before registration were dropped byis_event_supported(), leaving those seeded events stuck indev->valsuntil the nextSYN_REPORTafter registration.
Quoted 8 lines
Always accept
EV_SYNininput_event()andinput_inject_event()without checkingdev->evbitsoinput_sync()flushesdev->valsas intended.Reported-by Karlos Abel <[email protected]>,Fixes 0cd587735205 ("Input: preallocate memory to hold event values")Assisted-by LLMSigned-off-by Dmitry Torokhov <[email protected]>
Makes sense to me, thanks. FWIW:
Signature · 2 lines
Jiri Kosina SUSE Labs