]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: skip EVDEV_ABS override on devices without EV_ABS (#5984)
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 19 May 2017 08:56:29 +0000 (18:56 +1000)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 May 2017 08:56:29 +0000 (10:56 +0200)
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

src/udev/udev-builtin-keyboard.c

index 55f44daf59a8521ce2618fc4d72970e9fd58a8ad..e316bb93ba99841dc00fb5acd6a7fc4d572046be 100644 (file)
@@ -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));