From 640208531c5bd1765201ce65d2a83ae082e0271d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Mon, 3 Oct 2022 12:53:22 +0200 Subject: [PATCH] tablet: avoid errors calling libevdev_get_abs_info() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 806d4a1393db ("tablet: check libevdev_get_abs_info() return value") prevented a crash when tilt was deactivated by a quirk. For more information check [1]. Add similar checks before calling libevdev_get_abs_info() to avoid possible crashes. [1] https://gitlab.freedesktop.org/libinput/libinput/-/issues/805 Signed-off-by: José Expósito --- src/evdev-tablet.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 6094bd53..68c3c3e4 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -455,6 +455,10 @@ tablet_update_xy(struct tablet_dispatch *tablet, const struct input_absinfo *absinfo; int value; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_X) || + !libevdev_has_event_code(device->evdev, EV_ABS, ABS_Y)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X) || bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_X); @@ -528,6 +532,9 @@ tablet_update_pressure(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_PRESSURE)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_PRESSURE); @@ -541,6 +548,9 @@ tablet_update_distance(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_DISTANCE)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_DISTANCE); @@ -554,6 +564,9 @@ tablet_update_slider(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_WHEEL)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_WHEEL); @@ -597,6 +610,9 @@ tablet_update_artpen_rotation(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_Z)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) { absinfo = libevdev_get_abs_info(device->evdev,