]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: atmel_mxt_ts - fix boundary check in mxt_prepare_cfg_mem
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 4 May 2026 18:54:45 +0000 (11:54 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 7 May 2026 17:09:05 +0000 (10:09 -0700)
When a configuration file provides an object size that is larger than the
driver's known mxt_obj_size(object), the driver intends to discard the
extra bytes.

The loop iterates using for (i = 0; i < size; i++). Inside the loop, the
condition to skip processing extra bytes is:

    if (i > mxt_obj_size(object))
        continue;

Since i is a 0-based index, the valid indices for the object are 0 through
mxt_obj_size(object) - 1.

When i == mxt_obj_size(object), the condition evaluates to false, and the
code processes the byte instead of discarding it.

This causes the code to calculate byte_offset = reg + i - cfg->start_ofs
and writes the byte there, overwriting exactly one byte of the adjacent
instance or object.

Update the boundary check to skip extra bytes correctly by using >=.

Fixes: 50a77c658b80 ("Input: atmel_mxt_ts - download device config using firmware loader")
Cc: stable@vger.kernel.org
Assisted-by: Gemini:gemini-3.1-pro
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Link: https://patch.msgid.link/20260504185448.4055973-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/atmel_mxt_ts.c

index 87c6a10381f2de3ac0c70ea1f35e0e8cfc09568c..fad1b3f4138b8cbb5d99ef04680f8495985a007f 100644 (file)
@@ -1473,7 +1473,7 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data, struct mxt_cfg *cfg)
                        }
                        cfg->raw_pos += offset;
 
-                       if (i > mxt_obj_size(object))
+                       if (i >= mxt_obj_size(object))
                                continue;
 
                        byte_offset = reg + i - cfg->start_ofs;