From: Peter Hutterer Date: Fri, 19 May 2017 08:56:29 +0000 (+1000) Subject: udev: skip EVDEV_ABS override on devices without EV_ABS (#5984) X-Git-Tag: v234~192 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=855cf359b26b5dfa93351da1cb7c728f9d656b0e;p=platform%2Fupstream%2Fsystemd.git udev: skip EVDEV_ABS override on devices without EV_ABS (#5984) When we first handle a device with an EVDEV_ABS override, check if it has EV_ABS bits. If not, print a warning and continue. This is required on devices where the match string applies to multiple device nodes, not all of which may have absolute axes. Fixes https://github.com/systemd/systemd/issues/5079 --- diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c index 55f44da..e316bb9 100644 --- a/src/udev/udev-builtin-keyboard.c +++ b/src/udev/udev-builtin-keyboard.c @@ -201,6 +201,7 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo unsigned release_count = 0; _cleanup_close_ int fd = -1; const char *node; + int has_abs = -1; node = udev_device_get_devnode(dev); if (!node) { @@ -261,6 +262,24 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo return EXIT_FAILURE; } + if (has_abs == -1) { + unsigned long bits; + int rc; + + rc = ioctl(fd, EVIOCGBIT(0, sizeof(bits)), &bits); + if (rc < 0) { + log_error_errno(errno, "Unable to EVIOCGBIT device \"%s\"", node); + return EXIT_FAILURE; + } + + has_abs = !!(bits & (1 << EV_ABS)); + if (!has_abs) + log_warning("EVDEV_ABS override set but no EV_ABS present on device \"%s\"", node); + } + + if (!has_abs) + continue; + override_abs(fd, node, evcode, udev_list_entry_get_value(entry)); } else if (streq(key, "POINTINGSTICK_SENSITIVITY")) set_trackpoint_sensitivity(dev, udev_list_entry_get_value(entry));