]> git.ipfire.org Git - thirdparty/linux.git/commit
Input: elan_i2c - prevent division by zero and arithmetic underflow
authorRanjan Kumar <kumarranja@chromium.org>
Tue, 23 Jun 2026 05:31:05 +0000 (22:31 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 23 Jun 2026 05:33:02 +0000 (22:33 -0700)
commitdf2b818fa009c10ff6ba875a1663ff001cda9558
tree35b15b3a70583e1045128a5b6828fe5b1412d12b
parentef166ce08801c5237662868d9ec0331d53a38ece
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: 6696777c6506 ("Input: add driver for Elan I2C/SMbus touchpad")
Fixes: e3a9a1290688 ("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>
drivers/input/mouse/elan_i2c_core.c