xserver: Branch 'master' - 5 commits

Keith Packard keithp at kemper.freedesktop.org
Thu May 9 19:57:37 PDT 2013


 Xi/exevents.c      |   16 ++++++++++------
 dix/devices.c      |   41 ++++++++++++++++++++++++++++++++---------
 dix/dispatch.c     |    1 +
 dix/dixutils.c     |    8 +++++++-
 dix/main.c         |    2 ++
 include/callback.h |    1 +
 os/io.c            |    1 +
 xkb/xkbInit.c      |    8 +++++---
 8 files changed, 59 insertions(+), 19 deletions(-)

New commits:
commit 2f1aedcaed8fd99b823d451bf1fb02330c078f67
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 9 14:30:50 2013 +1000

    input: print warnings if drivers don't initialize properly
    
    If drivers supply incorrect values don't just quietly return False, spew to
    the log so we can detect what's going on. All these cases are driver bugs
    and should be fixed immediately.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 7eb71ee..3088257 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -2023,6 +2023,9 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev)
 {
     ProximityClassPtr proxc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->proximity != NULL, FALSE);
+
     proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec));
     if (!proxc)
         return FALSE;
@@ -2048,10 +2051,10 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
 {
     AxisInfoPtr ax;
 
-    if (!dev || !dev->valuator || (minval > maxval && mode == Absolute))
-        return FALSE;
-    if (axnum >= dev->valuator->numAxes)
-        return FALSE;
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->valuator == NULL, FALSE);
+    BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE);
+    BUG_RETURN_VAL(minval > maxval && mode == Absolute, FALSE);
 
     ax = dev->valuator->axes + axnum;
 
@@ -2081,8 +2084,9 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type,
     InternalEvent dce;
     DeviceIntPtr master;
 
-    if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes)
-        return FALSE;
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->valuator == NULL, FALSE);
+    BUG_RETURN_VAL(axnum >= dev->valuator->numAxes, FALSE);
 
     switch (type) {
     case SCROLL_TYPE_VERTICAL:
diff --git a/dix/devices.c b/dix/devices.c
index 767b5c7..9b6faee 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1277,6 +1277,9 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom *labels,
     ButtonClassPtr butc;
     int i;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->button != NULL, FALSE);
+
     butc = calloc(1, sizeof(ButtonClassRec));
     if (!butc)
         return FALSE;
@@ -1337,8 +1340,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     int i;
     ValuatorClassPtr valc;
 
-    if (!dev)
-        return FALSE;
+    BUG_RETURN_VAL(dev == NULL, FALSE);
 
     if (numAxes > MAX_VALUATORS) {
         LogMessage(X_WARNING,
@@ -1447,6 +1449,9 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
 {
     FocusClassPtr focc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->focus != NULL, FALSE);
+
     focc = malloc(sizeof(FocusClassRec));
     if (!focc)
         return FALSE;
@@ -1466,6 +1471,9 @@ InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
 {
     PtrFeedbackPtr feedc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->ptrfeed != NULL, FALSE);
+
     feedc = malloc(sizeof(PtrFeedbackClassRec));
     if (!feedc)
         return FALSE;
@@ -1507,6 +1515,9 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev,
     int i;
     StringFeedbackPtr feedc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->stringfeed != NULL, FALSE);
+
     feedc = malloc(sizeof(StringFeedbackClassRec));
     if (!feedc)
         return FALSE;
@@ -1541,6 +1552,9 @@ InitBellFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
 {
     BellFeedbackPtr feedc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->bell != NULL, FALSE);
+
     feedc = malloc(sizeof(BellFeedbackClassRec));
     if (!feedc)
         return FALSE;
@@ -1560,6 +1574,9 @@ InitLedFeedbackClassDeviceStruct(DeviceIntPtr dev, LedCtrlProcPtr controlProc)
 {
     LedFeedbackPtr feedc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->leds != NULL, FALSE);
+
     feedc = malloc(sizeof(LedFeedbackClassRec));
     if (!feedc)
         return FALSE;
@@ -1580,6 +1597,9 @@ InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr dev,
 {
     IntegerFeedbackPtr feedc;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->intfeed != NULL, FALSE);
+
     feedc = malloc(sizeof(IntegerFeedbackClassRec));
     if (!feedc)
         return FALSE;
@@ -1600,6 +1620,11 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
 {
     DeviceIntPtr dev = (DeviceIntPtr) device;
 
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->button != NULL, FALSE);
+    BUG_RETURN_VAL(dev->valuator != NULL, FALSE);
+    BUG_RETURN_VAL(dev->ptrfeed != NULL, FALSE);
+
     return (InitButtonClassDeviceStruct(dev, numButtons, btn_labels, map) &&
             InitValuatorClassDeviceStruct(dev, numAxes, axes_labels,
                                           numMotionEvents, Relative) &&
@@ -1620,14 +1645,12 @@ InitTouchClassDeviceStruct(DeviceIntPtr device, unsigned int max_touches,
     TouchClassPtr touch;
     int i;
 
-    if (device->touch || !device->valuator)
-        return FALSE;
+    BUG_RETURN_VAL(device == NULL, FALSE);
+    BUG_RETURN_VAL(device->touch != NULL, FALSE);
 
     /* Check the mode is valid, and at least X and Y axes. */
-    if (mode != XIDirectTouch && mode != XIDependentTouch)
-        return FALSE;
-    if (num_axes < 2)
-        return FALSE;
+    BUG_RETURN_VAL(mode != XIDirectTouch && mode != XIDependentTouch, FALSE);
+    BUG_RETURN_VAL(num_axes < 2, FALSE);
 
     if (num_axes > MAX_VALUATORS) {
         LogMessage(X_WARNING,
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 573c4ff..5308a29 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -503,8 +503,9 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
     XkbEventCauseRec cause;
     XkbRMLVOSet rmlvo_dflts = { NULL };
 
-    if (dev->key || dev->kbdfeed)
-        return FALSE;
+    BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(dev->key != NULL, FALSE);
+    BUG_RETURN_VAL(dev->kbdfeed != NULL, FALSE);
 
     if (!rmlvo) {
         rmlvo = &rmlvo_dflts;
commit 8a88b0ab52ba375ae84463a90503db88af10e368
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 9 14:30:49 2013 +1000

    dix: don't overwrite proximity/focus classes
    
    InitPointerClassDeviceStruct/InitKeyboardDeviceStruct allocate a
    proximity/focus class, respectively. If a driver calls
    InitFocusClassDeviceStruct or InitProximityClassDeviceStruct beforehand,
    the previously allocated class is overwritten, leaking the memory.
    
    Neither takes a parameter other than the device, so we can simply skip
    initialising it if we already have one.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/dix/devices.c b/dix/devices.c
index 0c718d2..767b5c7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1367,7 +1367,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     valc->numMotionEvents = numMotionEvents;
     valc->motionHintWindow = NullWindow;
 
-    if (mode & OutOfProximity)
+    if ((mode & OutOfProximity) && !dev->proximity)
         InitProximityClassDeviceStruct(dev);
 
     dev->valuator = valc;
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 244c353..573c4ff 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -589,7 +589,8 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
     XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes,
                      &check, &cause);
 
-    InitFocusClassDeviceStruct(dev);
+    if (!dev->focus)
+        InitFocusClassDeviceStruct(dev);
 
     xkbi->kbdProc = ctrl_func;
     dev->kbdfeed->BellProc = bell_func;
commit 34b0d07ebf4a7874fe7fd336bef5bbdd8debda1c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri May 10 09:44:29 2013 +1000

    dix: reset the OsBuffers after killing all clients
    
    ==21860== 24 bytes in 1 blocks are still reachable in loss record 85 of 397
    ==21860==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==21860==    by 0x61ED93: AllocateOutputBuffer (io.c:1037)
    ==21860==    by 0x61E15A: WriteToClient (io.c:764)
    ==21860==    by 0x457B30: ProcQueryExtension (extension.c:275)
    ==21860==    by 0x43596B: Dispatch (dispatch.c:432)
    ==21860==    by 0x425DAB: main (main.c:295)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 90b6c7c..1363f22 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -465,6 +465,7 @@ Dispatch(void)
     free(clientReady);
     dispatchException &= ~DE_RESET;
     SmartScheduleLatencyLimited = 0;
+    ResetOsBuffers();
 }
 
 static int VendorRelease = VENDOR_RELEASE;
commit 67c66606c760c263d7a4c2d1bba43ed6225a4e7c
Author: Robert Morell <rmorell at nvidia.com>
Date:   Thu May 9 13:09:02 2013 -0700

    os: Reset input buffer's 'ignoreBytes' field
    
    If a client sends a request larger than maxBigRequestSize, the server is
    supposed to ignore it.
    
    Before commit cf88363d, the server would simply disconnect the client.  After
    that commit, it attempts to gracefully ignore the request by remembering how
    long the client specified the request to be, and ignoring that many bytes.
    However, if a client sends a BigReq header with a large size and disconnects
    before actually sending the rest of the specified request, the server will
    reuse the ConnectionInput buffer without resetting the ignoreBytes field.  This
    makes the server ignore new X clients' requests.
    
    This fixes that behavior by resetting the ignoreBytes field when putting the
    ConnectionInput buffer back on the FreeInputs list.
    
    Signed-off-by: Robert Morell <rmorell at nvidia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/os/io.c b/os/io.c
index 2f091c4..0d980ab 100644
--- a/os/io.c
+++ b/os/io.c
@@ -1063,6 +1063,7 @@ FreeOsBuffers(OsCommPtr oc)
             oci->bufptr = oci->buffer;
             oci->bufcnt = 0;
             oci->lenLastReq = 0;
+            oci->ignoreBytes = 0;
         }
     }
     if ((oco = oc->output)) {
commit ddc11397a56c745b5d1fb377e9d9b1fcc73802c8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Feb 27 18:36:39 2012 +1000

    dix: delete all callbacks before reset
    
    DeleteCallbackManager() introduced for better symmetry in the caller, they
    do the same thing.
    
    ==20085== 24 bytes in 1 blocks are still reachable in loss record 11 of 103
    ==20085==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
    ==20085==    by 0x43A097: CreateCallbackList (dixutils.c:837)
    ==20085==    by 0x43A1D3: AddCallback (dixutils.c:869)
    ==20085==    by 0x4B1736: GEExtensionInit (geext.c:209)
    ==20085==    by 0x41C8A8: InitExtensions (miinitext.c:389)
    ==20085==    by 0x5AC918: main (main.c:208)
    
    ==2042== 8 bytes in 1 blocks are still reachable in loss record 2 of 97
    ==2042==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
    ==2042==    by 0x4C2A657: realloc (vg_replace_malloc.c:525)
    ==2042==    by 0x4802F5: XNFrealloc (utils.c:1095)
    ==2042==    by 0x43A17A: CreateCallbackList (dixutils.c:855)
    ==2042==    by 0x43A1EF: AddCallback (dixutils.c:870)
    ==2042==    by 0x4B1752: GEExtensionInit (geext.c:209)
    ==2042==    by 0x41C8A8: InitExtensions (miinitext.c:389)
    ==2042==    by 0x5AC9E4: main (main.c:208)
    ==2042==
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 3f24629..c250bb1 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -849,7 +849,7 @@ DeleteCallbackList(CallbackListPtr *pcbl)
 }
 
 void
-InitCallbackManager(void)
+DeleteCallbackManager(void)
 {
     int i;
 
@@ -861,3 +861,9 @@ InitCallbackManager(void)
     numCallbackListsToCleanup = 0;
     listsToCleanup = NULL;
 }
+
+void
+InitCallbackManager(void)
+{
+    DeleteCallbackManager();
+}
diff --git a/dix/main.c b/dix/main.c
index 1fa0504..e69cd93 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -366,6 +366,8 @@ main(int argc, char *argv[], char *envp[])
 
         FreeAuditTimer();
 
+        DeleteCallbackManager();
+
         if (dispatchException & DE_TERMINATE) {
             CloseWellKnownConnections();
         }
diff --git a/include/callback.h b/include/callback.h
index ed6b678..b427089 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -86,5 +86,6 @@ CallCallbacks(CallbackListPtr *pcbl, pointer call_data)
 extern _X_EXPORT void DeleteCallbackList(CallbackListPtr * /*pcbl */ );
 
 extern _X_EXPORT void InitCallbackManager(void);
+extern _X_EXPORT void DeleteCallbackManager(void);
 
 #endif                          /* CALLBACK_H */


More information about the xorg-commit mailing list