Re: [PATCH] Input: elan_i2c - prevent division by zero on invalid device parameters
From: Dmitry Torokhov
Date: Wed May 13 2026 - 17:02:47 EST
Hi Ranjan,
On Wed, May 13, 2026 at 07:39:08AM +0000, Ranjan Kumar wrote:
> 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, y_traces, x_mm, or y_mm, it results in a fatal
> division-by-zero exception leading to a kernel panic during device probe.
>
Neither crashing nor aborting probe with -EINVAL is great as we will not
be able to flash another firmware.
How do we get into this state? Is this something actually observed or
just theoretical?
> Add sanity checks to ensure these physical parameters are non-zero
> before performing the division. If invalid values are detected, log an
> error and return -EINVAL to gracefully abort the initialization and
> maintain system stability.
That is hardly "stability" for a laptop when its pointer is not working.
Thanks.
--
Dmitry