[PATCH v5 0/2] HID: multitouch: fix use-after-free of haptic data on delayed input release

From: Aldo Ariel Panzardo

Date: Fri Oct 16 2026 - 10:03:23 EST


Hi Benjamin,

Thanks for the feedback on v4. Reworked as you asked -- devm_kzalloc
stays, a devm_add_action() handles teardown, and the try_module_get
reorder is now a separate patch.

Patch 1 moves try_module_get()/get_device() before input_ff_create()
so the old input_free error path (which returned ret == 0) goes away.

Patch 2 adds a devm_add_action() callback in hid_haptic_init() that
does all the resource teardown at unbind. hid_haptic_destroy() just
sets ff->private = NULL so the subsequent kfree in input_ff_destroy
is harmless. input_get_device() pins the input device for the
duration of the devres action.

Changes since v4:
- keep devm_kzalloc, use devm_add_action (Benjamin)
- split reorder into its own patch (Benjamin)
- single-owner teardown -- destroy only NULLs ff->private,
devm action owns workqueue drain + buffer frees + ref puts
- input_get_device pins input_dev against concurrent release
- workqueue drained before any pointer NULLs or frees
- input_ff_destroy on devm_add_action failure
- no hid-multitouch.c or hid-haptic.h changes

v4: https://lore.kernel.org/linux-input/20261009103333.2476105-1-qwe.aldo@xxxxxxxxx/
v3: https://lore.kernel.org/linux-input/20261009110509.2432308-1-qwe.aldo@xxxxxxxxx/
v1: https://lore.kernel.org/linux-input/20261009031207.3233206-1-qwe.aldo@xxxxxxxxx/

Aldo Ariel Panzardo (2):
HID: haptic: reorder try_module_get/get_device before input_ff_create
HID: multitouch: fix use-after-free of haptic data on delayed input
release

drivers/hid/hid-haptic.c | 87 ++++++++++++++++++++++++++++------------
1 file changed, 62 insertions(+), 25 deletions(-)

--
2.53.0