[PATCH aiptek 2/3] Only free the device->common if we actually have a device.

Peter Hutterer peter.hutterer at who-t.net
Sun Jun 26 21:26:48 PDT 2011


This function is nonetheless rather dubious. Common may be shared between
multiple devices. AFAIU this code sets xCapacity to -10101 so that when
UnInit is called on the other devices they don't double free. It's almost
like a poor man's refcounting, but with a lot less refcounting and a lot
more guffawing.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xf86Aiptek.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/xf86Aiptek.c b/src/xf86Aiptek.c
index 8421a70..3a60d13 100644
--- a/src/xf86Aiptek.c
+++ b/src/xf86Aiptek.c
@@ -1781,12 +1781,15 @@ xf86AiptekUninit(InputDriverPtr    drv,
 
     DBG(1, "xf86AiptekUninit\n");
 
-    if (device->common && device->common->xCapacity != -10101)
+    if (device)
     {
-        device->common->xCapacity = -10101;
-        free(device->common);
+        if (device->common && device->common->xCapacity != -10101)
+        {
+            device->common->xCapacity = -10101;
+            free(device->common);
+        }
+        free (device);
     }
-    free (device);
     pInfo->private = NULL;
     xf86DeleteInput(pInfo, 0);
 }
-- 
1.7.5.4



More information about the xorg-devel mailing list