summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-06-29 09:58:40 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-06-29 09:58:40 +1000
commitdc276f43b3ad03437635cc125de5905ec403c15d (patch)
treea465450c4833a1826662dc7d04928d00a03049ab
parent62413b8a00a837d28b6135d752ed5bdb0aa3f162 (diff)
Remove references to other devices after shutdown.
deviceArray keeps a ref to each InputInfoPtr this driver (on this device) handles. These need to be unset and removed, otherwise an event coming in after the shutdown of one device may dereference an invalid pointer. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/xf86Aiptek.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/xf86Aiptek.c b/src/xf86Aiptek.c
index d41f890..a68814f 100644
--- a/src/xf86Aiptek.c
+++ b/src/xf86Aiptek.c
@@ -1785,9 +1785,21 @@ xf86AiptekUninit(InputDriverPtr drv,
{
if (device->common)
{
- device->common->numDevices--;
- if (device->common->numDevices == 0)
- free(device->common);
+ AiptekCommonPtr common = device->common;
+ int i;
+
+ common->numDevices--;
+
+ for (i = 0; i < common->numDevices; i++)
+ {
+ if (common->deviceArray[i] == pInfo)
+ memmove(&common->deviceArray[i],
+ &common->deviceArray[i+1],
+ (common->numDevices - i) * sizeof(InputInfoPtr));
+ }
+
+ if (common->numDevices == 0)
+ free(common);
}
device->common = NULL;
}