From 81c5950d0af8d5859f850b98c98a532784e9a757 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:47:21 +0200 Subject: [PATCH 1/6] Config: D-Bus: Don't leak timers TimerCancel doesn't free the timer: you need TimerFree for that. (cherry picked from commit 25deaa7e6b29b3913b35efa39b9c8b25de5e6d95) --- config/dbus-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/dbus-core.c b/config/dbus-core.c index eab72a530..9cf153076 100644 --- a/config/dbus-core.c +++ b/config/dbus-core.c @@ -76,7 +76,7 @@ teardown(void) struct config_dbus_core_hook *hook; if (bus_info.timer) { - TimerCancel(bus_info.timer); + TimerFree(bus_info.timer); bus_info.timer = NULL; } @@ -116,6 +116,8 @@ message_filter(DBusConnection *connection, DBusMessage *message, void *data) bus_info.connection = NULL; teardown(); + if (bus_info.timer) + TimerFree(bus_info.timer); bus_info.timer = TimerSet(NULL, 0, 1, reconnect_timer, NULL); return DBUS_HANDLER_RESULT_HANDLED; @@ -186,6 +188,7 @@ static CARD32 reconnect_timer(OsTimerPtr timer, CARD32 time, pointer arg) { if (connect_to_bus()) { + TimerFree(bus_info.timer); bus_info.timer = NULL; return 0; } From 30fc8053a5e734c3b70156bdae94fd7d5d7865a5 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:47:57 +0200 Subject: [PATCH 2/6] Config: HAL: Don't leak options on failure to add device This showed up in Xephyr in particular, which denies new device requests. (cherry picked from commit 2bb199056edf6c63cf978d1a8ad49a57ce1938f3) --- config/hal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/hal.c b/config/hal.c index 4427deb39..16f16ecb8 100644 --- a/config/hal.c +++ b/config/hal.c @@ -92,6 +92,8 @@ add_option(InputOption **options, const char *key, const char *value) for (; *options; options = &(*options)->next) ; *options = xcalloc(sizeof(**options), 1); + if (!*options) /* Yeesh. */ + return; (*options)->key = xstrdup(key); (*options)->value = xstrdup(value); (*options)->next = NULL; @@ -156,7 +158,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) char *path = NULL, *driver = NULL, *name = NULL, *xkb_rules = NULL; char *xkb_model = NULL, *xkb_layout = NULL, *xkb_variant = NULL; char *xkb_options = NULL, *config_info = NULL; - InputOption *options = NULL; + InputOption *options = NULL, *tmpo = NULL; DeviceIntPtr dev; DBusError error; int type = TYPE_NONE; @@ -232,6 +234,7 @@ device_added(LibHalContext *hal_ctx, const char *udi) if (NewInputDeviceRequest(options, &dev) != Success) { DebugF("[config/hal] NewInputDeviceRequest failed\n"); + dev = NULL; goto unwind; } @@ -255,6 +258,12 @@ unwind: xfree(xkb_options); if (config_info) xfree(config_info); + while (!dev && (tmpo = options)) { + options = tmpo->next; + xfree(tmpo->key); + xfree(tmpo->value); + xfree(tmpo); + } out_error: dbus_error_free(&error); From 38d8cfaaff0ae6273d9e921aae08b2706355f0d2 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:48:25 +0200 Subject: [PATCH 3/6] OS: Don't leak connection translation table on regeneration (cherry picked from commit e868e0bc0d2318e62707d3ae68532b0029959154) --- os/connection.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os/connection.c b/os/connection.c index b94459366..d1ba845ef 100644 --- a/os/connection.c +++ b/os/connection.c @@ -353,7 +353,8 @@ InitConnectionLimits(void) #endif #if !defined(WIN32) - ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); + if (!ConnectionTranslation) + ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); #else InitConnectionTranslation(); #endif From a304fc1d4a7062f65161ef8748fd358639ec73de Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:48:57 +0200 Subject: [PATCH 4/6] KDrive: Xephyr: Don't leak screen damage structure (cherry picked from commit 0b03d97a244540824c922c300adbc3d3ae4855d5) --- hw/kdrive/ephyr/ephyr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e8001df73..27165a5a2 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -394,6 +394,7 @@ ephyrUnsetInternalDamage (ScreenPtr pScreen) pPixmap = (*pScreen->GetScreenPixmap) (pScreen); DamageUnregister (&pPixmap->drawable, scrpriv->pDamage); + DamageDestroy (scrpriv->pDamage); RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler, ephyrInternalDamageWakeupHandler, From 102c012c206cbb3bbf0fa5b0c8f0ce2ce9bba72a Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:49:50 +0200 Subject: [PATCH 5/6] Input: Don't reinit devices If a device is already initialised (i.e. the virtual core devices) during IASD, don't init them again. This fixes a leak. (cherry picked from commit 1f6015c8fe62c28cfaa82cc855b5b9c28fd34607) --- dix/devices.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dix/devices.c b/dix/devices.c index 287d730a3..f6f3c8ece 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -473,7 +473,8 @@ InitAndStartDevices(void) for (dev = inputInfo.off_devices; dev; dev = dev->next) { DebugF("(dix) initialising device %d\n", dev->id); - ActivateDevice(dev); + if (!dev->inited) + ActivateDevice(dev); } for (dev = inputInfo.off_devices; dev; dev = next) { From 60144ac814ee26e151186f7c93cb1a273468d497 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 Dec 2007 16:20:36 +1030 Subject: [PATCH 6/6] include: never overwrite realInputProc with enqueueInputProc. Bug #13511 In some cases (triggered by a key repeat during a sync grab) XKB unwrapping can overwrite the device's realInputProc with the enqueueInputProc. When the grab is released and the events are replayed, we end up in an infinite loop. Each event is replayed and in replaying pushed to the end of the queue again. This fix is a hack only. It ensures that the realInputProc is never overwritten with the enqueueInputProc. This fixes Bug #13511 (https://bugs.freedesktop.org/show_bug.cgi?id=13511) (cherry picked from commit eace88989c3b65d5c20e9f37ea9b23c7c8e19335) (cherry picked from commit 50e80c39870adfdc84fdbc00dddf1362117ad443) --- include/xkbsrv.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 167dbec59..9174eb64e 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -258,7 +258,8 @@ typedef struct device->public.processInputProc = proc; \ oldprocs->processInputProc = \ oldprocs->realInputProc = device->public.realInputProc; \ - device->public.realInputProc = proc; \ + if (proc != device->public.enqueueInputProc) \ + device->public.realInputProc = proc; \ oldprocs->unwrapProc = device->unwrapProc; \ device->unwrapProc = unwrapproc;