[PATCH synaptics] eventcomm: prevent possibly division by zero

Hans de Goede hdegoede at redhat.com
Mon Mar 23 04:07:50 PDT 2015


Hi,

On 23-03-15 02:51, Peter Hutterer wrote:
> This came up as a kernel bug, but it's valid to create uinput devices with a
> min == max range for x/y. Technically valid, but effectively useless, so catch
> it, complain and hobble on along.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

> ---
>   src/eventcomm.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 53a0ca4..cddf7fc 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -436,6 +436,11 @@ event_query_axis_ranges(InputInfoPtr pInfo)
>       event_get_abs(proto_data->evdev, ABS_Y, &priv->miny, &priv->maxy,
>                     &priv->synpara.hyst_y, &priv->resy);
>
> +    if (priv->minx == priv->maxx || priv->miny == priv->maxy) {
> +        xf86IDrvMsg(pInfo, X_ERROR, "Kernel bug: min == max on ABS_X/Y\n");
> +        return;
> +    }
> +
>       priv->has_pressure = libevdev_has_event_code(proto_data->evdev, EV_ABS, ABS_PRESSURE);
>       priv->has_width = libevdev_has_event_code(proto_data->evdev, EV_ABS, ABS_TOOL_WIDTH);
>
> @@ -458,6 +463,11 @@ event_query_axis_ranges(InputInfoPtr pInfo)
>           event_get_abs(proto_data->evdev, ABS_MT_POSITION_Y, &priv->miny,
>                         &priv->maxy, &priv->synpara.hyst_y, &priv->resy);
>
> +        if (priv->minx == priv->maxx || priv->miny == priv->maxy) {
> +            xf86IDrvMsg(pInfo, X_ERROR, "Kernel bug: min == max on ABS_MT_POSITION_X/Y\n");
> +            return;
> +        }
> +
>           proto_data->st_to_mt_offset[0] = priv->minx - st_minx;
>           proto_data->st_to_mt_scale[0] =
>               (priv->maxx - priv->minx) / (st_maxx - st_minx);
>


More information about the xorg-devel mailing list