]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
Input: atmel_mxt_ts - check mem_size before calculating config memory size
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 4 May 2026 18:54:46 +0000 (11:54 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 7 May 2026 17:09:54 +0000 (10:09 -0700)
commita5fd88a5d63f812422e69682f3cb663d9d7f3e9c
treedde412e628c7d59ddf6c3d6a64c44d9e5357b175
parentbaa0210fb6a9dc3882509a9411b6d284d88fe30e
Input: atmel_mxt_ts - check mem_size before calculating config memory size

In mxt_update_cfg(), the driver calculates the memory size needed to store
the configuration as data->mem_size - cfg.start_ofs. If data->mem_size is
less than or equal to cfg.start_ofs, this calculation will underflow or
result in a zero-size buffer, neither of which is valid for a configuration
update.

Add a check to return -EINVAL if data->mem_size is too small. While at it,
change the types of start_ofs and mem_size in struct mxt_cfg to u16 to
match the device address space.

Assisted-by: Gemini:gemini-3.1-pro
Link: https://patch.msgid.link/20260504185448.4055973-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/atmel_mxt_ts.c