diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-05-28 09:50:57 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-06-08 09:12:14 +1000 |
commit | 047955f51e013c190bb09ba0c03ca2c160f34997 (patch) | |
tree | 4ce954579dbbf680c387d7c28ef10b7aeb46eca8 | |
parent | Close the fd when mtdev open fails (diff) | |
download | xf86-input-evdev-047955f51e013c190bb09ba0c03ca2c160f34997.tar.gz xf86-input-evdev-047955f51e013c190bb09ba0c03ca2c160f34997.tar.bz2 xf86-input-evdev-047955f51e013c190bb09ba0c03ca2c160f34997.zip |
Move duplicate check up before mtdev allocation
No need to alloc mtdev if we then find out the fd is a duplicate one anyway.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | src/evdev.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/evdev.c b/src/evdev.c index a4512cb..8d97243 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2349,6 +2349,15 @@ EvdevOpenDevice(InputInfoPtr pInfo) } } + /* Check major/minor of device node to avoid adding duplicate devices. */ + pEvdev->min_maj = EvdevGetMajorMinor(pInfo); + if (EvdevIsDuplicate(pInfo)) + { + xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n"); + EvdevCloseDevice(pInfo); + return BadMatch; + } + #ifdef MULTITOUCH pEvdev->mtdev = mtdev_new_open(pInfo->fd); if (pEvdev->mtdev) @@ -2360,15 +2369,6 @@ EvdevOpenDevice(InputInfoPtr pInfo) } #endif - /* Check major/minor of device node to avoid adding duplicate devices. */ - pEvdev->min_maj = EvdevGetMajorMinor(pInfo); - if (EvdevIsDuplicate(pInfo)) - { - xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n"); - EvdevCloseDevice(pInfo); - return BadMatch; - } - return Success; } |