From 57a02c4fdaf850af0d4cbf65dbf94c369879a322 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 7 Mar 2016 10:19:22 +1000 Subject: [PATCH] Fix segfault on mislabeled tablets (#1314955) --- ...et-reject-mislabelled-tablet-devices.patch | 66 +++++++++++++++++++ libinput.spec | 8 ++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 0001-tablet-reject-mislabelled-tablet-devices.patch diff --git a/0001-tablet-reject-mislabelled-tablet-devices.patch b/0001-tablet-reject-mislabelled-tablet-devices.patch new file mode 100644 index 0000000..f8e7071 --- /dev/null +++ b/0001-tablet-reject-mislabelled-tablet-devices.patch @@ -0,0 +1,66 @@ +From 821ac1f9d5ea1267ea125c67e7652c8cc14e9cb3 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Mon, 7 Mar 2016 10:12:13 +1000 +Subject: [PATCH libinput] tablet: reject mislabelled tablet devices + +The HUION 580 has a "consumer control" event node that has an ABS_VOLUME, keys +and a REL_HWHEEL. It has the same VID/PID as the pen tablet and libwacom +labels it as ID_INPUT_TABLET. This causes a crash later when we try to init +pointer acceleration for a device that doesn't have axes. + +https://bugzilla.redhat.com/show_bug.cgi?id=1314955 + +Signed-off-by: Peter Hutterer +--- + src/evdev-tablet.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c +index 0f6fa2c..9fc38aa 100644 +--- a/src/evdev-tablet.c ++++ b/src/evdev-tablet.c +@@ -1613,6 +1613,31 @@ tablet_init_left_handed(struct evdev_device *device) + } + + static int ++tablet_reject_device(struct evdev_device *device) ++{ ++ struct libevdev *evdev = device->evdev; ++ int rc = -1; ++ ++ if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) || ++ !libevdev_has_event_code(evdev, EV_ABS, ABS_Y)) ++ goto out; ++ ++ if (!libevdev_has_event_code(evdev, EV_KEY, BTN_TOOL_PEN)) ++ goto out; ++ ++ rc = 0; ++ ++out: ++ if (rc) { ++ log_bug_libinput(device->base.seat->libinput, ++ "Device '%s' does not meet tablet criteria. " ++ "Ignoring this device.\n", ++ device->devname, device->devname); ++ } ++ return rc; ++} ++ ++static int + tablet_init(struct tablet_dispatch *tablet, + struct evdev_device *device) + { +@@ -1625,6 +1650,9 @@ tablet_init(struct tablet_dispatch *tablet, + tablet->current_tool_type = LIBINPUT_TOOL_NONE; + list_init(&tablet->tool_list); + ++ if (tablet_reject_device(device)) ++ return -1; ++ + tablet_init_calibration(tablet, device); + tablet_init_proximity_threshold(tablet, device); + rc = tablet_init_accel(tablet, device); +-- +2.5.0 + diff --git a/libinput.spec b/libinput.spec index 84cc2a3..4236be8 100644 --- a/libinput.spec +++ b/libinput.spec @@ -5,7 +5,7 @@ Name: libinput Version: 1.2.1 -Release: 2%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} +Release: 3%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist} Summary: Input device library License: MIT @@ -21,6 +21,9 @@ Source0: http://www.freedesktop.org/software/libinput/libinput-%{version} # Not upstream, keep until kernel 4.2 or 4.1.x with dbf3c37086 Patch01: 0001-touchpad-serial-synaptics-need-to-fake-new-touches-o.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1314955 +Patch02: 0001-tablet-reject-mislabelled-tablet-devices.patch + BuildRequires: git BuildRequires: autoconf automake libtool pkgconfig BuildRequires: libevdev-devel @@ -97,6 +100,9 @@ find $RPM_BUILD_ROOT -name '*.la' -delete %changelog +* Mon Mar 07 2016 Peter Hutterer 1.2.1-3 +- Fix segfault on mislabeled tablets (#1314955) + * Wed Mar 02 2016 Peter Hutterer 1.2.1-2 - Add libwacom-devel to BuildRequires