From 047955f51e013c190bb09ba0c03ca2c160f34997 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 28 May 2012 09:50:57 +1000 Subject: 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 Reviewed-by: Chase Douglas --- src/evdev.c | 18 +++++++++--------- 1 file 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; } -- cgit v1.2.3