Input: hynitron_cstxxx - validate touch count and finger IDs
authorJianing Li <m13940358460@163.com>
Tue, 4 Aug 2026 04:18:52 +0000 (21:18 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 4 Aug 2026 04:51:42 +0000 (21:51 -0700)
commit27f380ef0e1d3de3cde114e02d33f9320ce3a5a6
treec5ed7461e3f307f34d1e6b9ca093bc170ff4a05d
parent90f305f2c7a30257c683e13f4bf7c798eea992a0
Input: hynitron_cstxxx - validate touch count and finger IDs

The driver allocates max_touch_num input slots, which are indexed from
zero through max_touch_num - 1. The current check allows a finger ID
equal to max_touch_num to reach cst3xx_report_contact(). While the input
core ignores out-of-range slot indices, reporting touch data without a
valid slot change corrupts the touch state of the previously active slot.

The touch count is read from the controller's report and is used to
index the fixed-size report buffer without first checking its range.
Reject counts larger than the supported number of touch slots before
checking the trailing byte or parsing touch data.

Reject finger IDs equal to or greater than max_touch_num, and return
immediately when an invalid finger ID is encountered so that corrupt
touch frames are discarded instead of reporting partial contact state.

The V821 Avaota F1 board configures the vendor driver with one touch
slot, so finger ID 1 is already invalid on that device.

Fixes: 66603243f528 ("Input: add driver for Hynitron cstxxx touchscreens")
Signed-off-by: Jianing Li <m13940358460@163.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260804031339.2379-1-m13940358460@163.com
Assisted-by: Antigravity:gemini-3.6-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/hynitron_cstxxx.c