[PATCH -- please apply] CloseDevice: call XkbRemoveResourceClient before freeing key class struct

Alan Coopersmith alan.coopersmith at sun.com
Mon Jan 4 18:21:54 PST 2010


XkbRemoveResourceClient() returns immediately if dev->key is NULL.
CloseDevice calls XkbRemoveResourceClient until it removes all resources.

If we free dev->key and NULL it before XkbRemoveResourceClient, then
infinite loop ensues, and the server appears to hang on exit or crash.

Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
---
 dix/devices.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index 6329d28..92b95ed 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -842,6 +842,9 @@ CloseDevice(DeviceIntPtr dev)
     if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc)
 	dev->valuator->accelScheme.AccelCleanupProc(dev);
 
+    while (dev->xkb_interest)
+	XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
+
     xfree(dev->name);
 
     classes = (ClassesPtr)&dev->key;
@@ -853,9 +856,6 @@ CloseDevice(DeviceIntPtr dev)
         FreeAllDeviceClasses(classes);
     }
 
-    while (dev->xkb_interest)
-	XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
-
     if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
         xfree(dev->spriteInfo->sprite->spriteTrace);
         xfree(dev->spriteInfo->sprite);
-- 
1.5.6.5



More information about the xorg-devel mailing list