[PATCH v2 evdev 1/3] Release leaked XKB options on input device disconnect.

Rami Ylimäki rami.ylimaki at vincit.fi
Tue Mar 8 01:23:45 PST 2011


Currently the XKB options duplicated in EvdevAddKeyClass are never
released. For example, connecting and disconnecting a bluetooth
keyboard repeatedly causes a steadily growing memory leak.

Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
---
 src/evdev.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 45873c1..18b7246 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2162,6 +2162,18 @@ EvdevOpenDevice(InputInfoPtr pInfo)
     return Success;
 }
 
+static void
+EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+{
+    EvdevPtr pEvdev = pInfo ? pInfo->private : NULL;
+    if (pEvdev)
+    {
+        /* Release strings allocated in EvdevAddKeyClass. */
+        XkbFreeRMLVOSet(&pEvdev->rmlvo, FALSE);
+    }
+    xf86DeleteInput(pInfo, flags);
+}
+
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
 static int NewEvdevPreInit(InputDriverPtr, InputInfoPtr, int);
 
@@ -2198,7 +2210,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
 
 
-    xf86DeleteInput(pInfo, 0);
+    EvdevUnInit(drv, pInfo, 0);
     return NULL;
 }
 
@@ -2277,7 +2289,7 @@ _X_EXPORT InputDriverRec EVDEV = {
     "evdev",
     NULL,
     EvdevPreInit,
-    NULL,
+    EvdevUnInit,
     NULL,
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
     evdevDefaults
-- 
1.6.3.3



More information about the xorg-devel mailing list