Input: refuse to register absolute devices without absinfo
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 31 Jan 2017 23:09:08 +0000 (15:09 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 1 Feb 2017 18:33:21 +0000 (10:33 -0800)
If device is supposed to send absolute events (i.e. EV_ABS bit is set in
dev->evbit) but dev->absinfo is not allocated, then the driver has done
something wrong, and we should not register such device. Otherwise we'll
crash later, when driver tries to send absolute event.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/input.c

index 6a75bb08b9ffb72e3fab4df2ee7fef91f56c9bc4..067d648028a22ff8963ed12c3a59ae1a0b5e3dfd 100644 (file)
@@ -2091,6 +2091,12 @@ int input_register_device(struct input_dev *dev)
        const char *path;
        int error;
 
+       if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {
+               dev_err(&dev->dev,
+                       "Absolute device without dev->absinfo, refusing to register\n");
+               return -EINVAL;
+       }
+
        if (dev->devres_managed) {
                devres = devres_alloc(devm_input_device_unregister,
                                      sizeof(struct input_devres), GFP_KERNEL);