From 13c8bd3fde3b0831921e59f84936022a16379d63 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 4 Jan 2010 18:21:54 -0800 Subject: CloseDevice: call XkbRemoveResourceClient before freeing key class struct 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 Reviewed-by: Peter Hutterer Reviewed-by: Daniel Stone Signed-off-by: Keith Packard --- dix/devices.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dix/devices.c') diff --git a/dix/devices.c b/dix/devices.c index 6329d2810..92b95ed69 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); -- cgit v1.2.3