Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: hynitron_cstxxx: reject out-of-range finger IDs
@ 2026-08-04  2:03 Jianing Li
  2026-08-04  2:17 ` sashiko-bot
  2026-08-04  3:13 ` [PATCH v2] Input: hynitron_cstxxx: validate touch count and " Jianing Li
  0 siblings, 2 replies; 5+ messages in thread
From: Jianing Li @ 2026-08-04  2:03 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, stable

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 input_mt_report_slot_state(), resulting
in an out-of-bounds slot access.

Reject IDs at the upper bound before using them as slot indexes.

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

Fixes: 66603243f528 ("Input: add driver for Hynitron cstxxx touchscreens")
Cc: stable@vger.kernel.org
Signed-off-by: Jianing Li <m13940358460@163.com>
---
 drivers/input/touchscreen/hynitron_cstxxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/hynitron_cstxxx.c b/drivers/input/touchscreen/hynitron_cstxxx.c
index f6139b1a8681..05e877b0d877 100644
--- a/drivers/input/touchscreen/hynitron_cstxxx.c
+++ b/drivers/input/touchscreen/hynitron_cstxxx.c
@@ -333,7 +333,7 @@ static void cst3xx_touch_report(struct i2c_client *client)
 		sw = (buf[idx] & 0x0f) >> 1;
 		finger_id = (buf[idx] >> 4) & 0x0f;
 
 		/* Sanity check we don't have more fingers than we expect */
-		if (ts_data->chip->max_touch_num < finger_id) {
+		if (finger_id >= ts_data->chip->max_touch_num) {
 			dev_err(&client->dev, "cst3xx touch read failure\n");
 			break;
 		}
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-04  4:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04  2:03 [PATCH] Input: hynitron_cstxxx: reject out-of-range finger IDs Jianing Li
2026-08-04  2:17 ` sashiko-bot
2026-08-04  3:13 ` [PATCH v2] Input: hynitron_cstxxx: validate touch count and " Jianing Li
2026-08-04  3:21   ` sashiko-bot
2026-08-04  4:51   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox