[PATCH evdev 4/8] Ignore out-of-range slots information

Benjamin Tissoires benjamin.tissoires at gmail.com
Wed Jan 9 10:21:18 PST 2013


Getting an out of range ABS_MT_SLOT value means that either the kernel
driver is broken or the device is sending more slots that it advertised.
In both cases, it's a bug in the kernel and processing the incoming
events for this bad slot may introduce end-user problems.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>
---
 src/evdev.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 9930f4e..1dccd34 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -798,29 +798,28 @@ EvdevProcessTouchEvent(InputInfoPtr pInfo, struct input_event *ev)
     } else
     {
         int slot_index = last_mt_vals_slot(pEvdev);
+        if (slot_index < 0) {
+            if (ev->code == ABS_MT_TRACKING_ID && ev->value >= 0)
+                LogMessageVerbSigSafe(X_WARNING, 0,
+                                "%s: Attempted to use values from out-of-range "
+                                "slot, touch events discarded.\n",
+                                pInfo->name);
+            return;
+        }
 
         if (pEvdev->slot_state == SLOTSTATE_EMPTY)
             pEvdev->slot_state = SLOTSTATE_UPDATE;
         if (ev->code == ABS_MT_TRACKING_ID) {
             if (ev->value >= 0) {
                 pEvdev->slot_state = SLOTSTATE_OPEN;
-
-                if (slot_index >= 0)
-                    valuator_mask_copy(pEvdev->mt_mask,
-                                       pEvdev->last_mt_vals[slot_index]);
-                else
-                    LogMessageVerbSigSafe(X_WARNING, 0,
-                                "%s: Attempted to copy values from out-of-range "
-                                "slot, touch events may be incorrect.\n",
-                                pInfo->name);
+                valuator_mask_copy(pEvdev->mt_mask,
+                                   pEvdev->last_mt_vals[slot_index]);
             } else
                 pEvdev->slot_state = SLOTSTATE_CLOSE;
         } else {
             map = pEvdev->axis_map[ev->code];
             valuator_mask_set(pEvdev->mt_mask, map, ev->value);
-            if (slot_index >= 0)
-                valuator_mask_set(pEvdev->last_mt_vals[slot_index], map,
-                                  ev->value);
+            valuator_mask_set(pEvdev->last_mt_vals[slot_index], map, ev->value);
         }
     }
 }
-- 
1.8.0.2



More information about the xorg-devel mailing list