xserver: Branch 'server-1.10-branch' - 4 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Jul 29 01:19:52 PDT 2011


 hw/xfree86/common/xf86Config.c |    3 +++
 hw/xfree86/common/xf86Init.c   |   32 +++++++++++++++++++++++++++-----
 hw/xfree86/common/xf86Option.c |    2 +-
 hw/xfree86/common/xf86Xinput.c |    1 +
 4 files changed, 32 insertions(+), 6 deletions(-)

New commits:
commit 50a7361cfcb9ef361afe77e283f4fd2a5b6214f5
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Jul 20 09:00:18 2011 +1000

    Initialize the fd to -1 for xorg.conf input devices.
    
    For hotplugged devices, xf86AllocateInput does that for us but the xorg.conf
    path is different. Since not all drivers reset the fd during PreInit but may
    still call close(pInfo->fd) in all cases, this can terminate the logging
    early.
    
    Reproducible: add a wacom driver InputDevice section with no Option Device.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    (cherry picked from commit 3798dd379c1ecf325f9907128fb66d20372f6876)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 114bdc3..58b30dd 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1222,6 +1222,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	    devs = xnfrealloc(servlayoutp->inputs,
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+            Pointer.fd = -1;
 	    *devs[count - 1] = Pointer;
 	    devs[count - 1]->options =
 				xf86addNewOption(devs[count -1]->options,
@@ -1267,6 +1268,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	    devs = xnfrealloc(servlayoutp->inputs,
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+            Pointer.fd = -1;
 	    *devs[count - 1] = Pointer;
 	    devs[count - 1]->options =
 				xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
@@ -1363,6 +1365,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	    devs = xnfrealloc(servlayoutp->inputs,
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+            Keyboard.fd = -1;
 	    *devs[count - 1] = Keyboard;
 	    devs[count - 1]->options =
 				xf86addNewOption(devs[count - 1]->options,
commit 2d94a7d8c2223243fd860bd01f6fdeff91856679
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jul 4 12:34:32 2011 +1000

    xfree86: NULL option values are technically valid, don't strdup them
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    (cherry picked from commit f2a6735cfc07789cca81852b24a85578f200d83d)

diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 480f386..a3a836f 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -340,7 +340,7 @@ pointer
 xf86AddNewOption(pointer head, const char *name, const char *val)
 {
     /* XXX These should actually be allocated in the parser library. */
-    char *tmp = strdup(val);
+    char *tmp = val ? strdup(val) : NULL;
     char *tmp_name = strdup(name);
 
     return xf86addNewOption(head, tmp_name, tmp);
commit f8f6783b9d4bc4106a33e43a1ddb9c0744e2c741
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jul 4 14:14:39 2011 +1000

    xfree86: duplicate xorg.conf device information before xf86NewInputDevice
    
    xf86ConfigLayout.inputs contains the information from the xorg.conf
    file. Passing this into xf86NewInputDevice means the device will get
    cleaned up on exit and the pointers in xf86ConfigLayout.inputs are left
    dangling. In the second server generation, this results in a server
    crash.
    
    Also, rename pDev to pInfo. pDev is pretty much reserved for DeviceIntPtr
    types.
    
    Reproducible: AutoAddDevices off and xorg.conf input sections, trigger
    server regeneration.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    (cherry picked from commit f0d7e9db28c374a3db359bcb63a7ce79fd84b541)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 0b36163..7d9bce9 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -791,6 +791,21 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 				 NULL);
 }
 
+static InputInfoPtr
+duplicateDevice(InputInfoPtr pInfo)
+{
+    InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
+    if (dup) {
+        dup->name = strdup(pInfo->name);
+        dup->driver = strdup(pInfo->driver);
+        dup->options = xf86OptionListDuplicate(pInfo->options);
+        /* type_name is a const string */
+        dup->type_name = pInfo->type_name;
+        dup->fd = -1;
+    }
+    return dup;
+}
+
 /*
  * InitInput --
  *      Initialize all supported input devices.
@@ -799,7 +814,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 void
 InitInput(int argc, char **argv)
 {
-    InputInfoPtr* pDev;
+    InputInfoPtr* pInfo;
     DeviceIntPtr dev;
 
     xf86Info.vtRequestsPending = FALSE;
@@ -809,14 +824,21 @@ InitInput(int argc, char **argv)
     GetEventList(&xf86Events);
 
     /* Initialize all configured input devices */
-    for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
+    for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
+        InputInfoPtr dup;
         /* Replace obsolete keyboard driver with kbd */
-        if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
-            strcpy((*pDev)->driver, "kbd");
+        if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
+            strcpy((*pInfo)->driver, "kbd");
         }
 
+        /* Data passed into xf86NewInputDevice will be freed on shutdown.
+         * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
+         * xorg.conf input devices in the second generation
+         */
+        dup = duplicateDevice(*pInfo);
+
         /* If one fails, the others will too */
-        if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
+        if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
             break;
     }
 
commit e6336c357251836caa4e76e305c066a363e382f6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jun 27 16:30:28 2011 +1000

    xfree86: Remove devices that failed to enable on startup
    
    Devices that succeeded during PreInit and DEVICE_INIT but failed in
    DEVICE_ON would be deleted through xf86DeleteInput but not removed from the
    list of input devices (and not turned off). The result was a double free on
    server shutdown.
    
    Fix this by calling RemoveDevice if EnableDevice fails.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    (cherry picked from commit 8ffddbcf72170e246826ee0f39f18989a29fa218)

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 2bac33a..579ee09 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -825,6 +825,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
         {
             OsReleaseSignals();
             xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
+            RemoveDevice(dev, TRUE);
             rval = BadMatch;
             goto unwind;
         }


More information about the xorg-commit mailing list