linux/drivers/input/mouse
Ranjan Kumar df2b818fa0 Input: elan_i2c - prevent division by zero and arithmetic underflow
The Elan I2C touchpad driver queries the device for its physical
dimensions and trace counts to calculate the device resolution and width.
However, if the device firmware or device tree provides invalid zero
values for x_traces or y_traces, it results in a fatal division-by-zero
exception leading to a kernel panic during device probe.

Add checks to ensure these parameters are non-zero before performing
the division. If invalid trace values are detected, fall back to a safe
default of 1.

Additionally, prevent an arithmetic underflow in the touch reporting
logic. Previously, if the calculated or fallback width was smaller than
ETP_FWIDTH_REDUCE (90), the subtraction would underflow, resulting in a
massive unsigned integer being reported to userspace. Clamp the adjusted
width to a minimum of 0 to safely handle small physical dimensions and
fallback scenarios.

Completing the probe with safe fallback values ensures the sysfs nodes
are created, keeping the firmware update path intact so a recovery
firmware can be flashed to the device.

Fixes: 6696777c65 ("Input: add driver for Elan I2C/SMbus touchpad")
Fixes: e3a9a12906 ("Input: elan_i2c - do not query the info if they are provided")
Signed-off-by: Ranjan Kumar <kumarranja@chromium.org>
Link: https://patch.msgid.link/20260612060339.3829666-1-kumarranja@chromium.org
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2026-06-22 22:33:02 -07:00
..
alps.c Input: alps - use standard workqueue when registering supplemental device 2026-03-12 11:16:29 -07:00
alps.h Input: alps - use standard workqueue when registering supplemental device 2026-03-12 11:16:29 -07:00
amimouse.c Input: switch back to struct platform_driver::remove() 2024-10-15 11:43:25 -07:00
appletouch.c Input: appletouch - refactor endpoint lookup 2026-03-30 16:54:41 -07:00
atarimouse.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
bcm5974.c Merge branch 'next' into for-linus 2026-04-19 18:28:57 -07:00
byd.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
byd.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
cyapa_gen3.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
cyapa_gen5.c Input: cyapa - remove redundant pm_runtime_mark_last_busy() calls 2025-12-13 01:23:01 -08:00
cyapa_gen6.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
cyapa.c Input: Use named initializers for arrays of i2c_device_data 2026-05-30 22:10:47 -07:00
cyapa.h
cypress_ps2.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cypress_ps2.h Input: cypress_ps2 - fix error handling when sending command fails 2024-07-03 13:48:53 -07:00
elan_i2c_core.c Input: elan_i2c - prevent division by zero and arithmetic underflow 2026-06-22 22:33:02 -07:00
elan_i2c_i2c.c Input: elan_i2c - increase device reset wait timeout after update FW 2026-04-23 10:36:46 -07:00
elan_i2c_smbus.c Merge branch 'next' into for-linus 2020-12-14 16:27:23 -08:00
elan_i2c.h Input: elan_i2c - reduce the resume time for controller in Whitebox 2021-09-06 22:30:34 -07:00
elantech.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
elantech.h Input: elantech - fix protocol errors for some trackpoints in SMBus mode 2020-12-11 00:15:05 -08:00
focaltech.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
focaltech.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
gpio_mouse.c Input: gpio_mouse - fix typos in comments 2022-06-22 15:29:35 -07:00
Kconfig Input updates for v7.1-rc0 2026-04-22 18:36:40 -07:00
lifebook.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
lifebook.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
logips2pp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
logips2pp.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
Makefile Input updates for v7.1-rc0 2026-04-22 18:36:40 -07:00
maplemouse.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
psmouse-base.c Input: psmouse - remove dedicated kpsmoused workqueue 2026-03-12 11:16:30 -07:00
psmouse-smbus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
psmouse.h Input: psmouse - remove dedicated kpsmoused workqueue 2026-03-12 11:16:30 -07:00
rpcmouse.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
sentelic.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sentelic.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
sermouse.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
synaptics_i2c.c Input: Use named initializers for arrays of i2c_device_data 2026-05-30 22:10:47 -07:00
synaptics_usb.c Input: synaptics_usb - refactor endpoint lookup 2026-03-30 16:54:41 -07:00
synaptics.c Input: synaptics - add LEN2058 to SMBus passlist for ThinkPad E490 2026-05-13 21:43:04 -07:00
synaptics.h Input: synaptics - fix crash when enabling pass-through port 2025-01-20 21:27:02 -08:00
touchkit_ps2.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
touchkit_ps2.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
trackpoint.c input: trackpoint - Enable doubletap by default on capable devices 2026-03-17 15:27:22 +02:00
trackpoint.h input: trackpoint - Enable doubletap by default on capable devices 2026-03-17 15:27:22 +02:00
vmmouse.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vmmouse.h Input: psmouse - drop all unneeded functions from mouse headers 2019-08-20 14:15:36 -07:00
vsxxxaa.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00