xserver: Branch 'master' - 9 commits

Adam Jackson ajax at kemper.freedesktop.org
Tue Mar 8 15:21:29 UTC 2016


 Xext/xvmc.c                           |   17 ++++++++++++++---
 dri3/dri3_request.c                   |    4 ++--
 glx/glxcmds.c                         |    9 ++-------
 hw/dmx/glxProxy/glxcmds.c             |    5 +----
 hw/xfree86/drivers/modesetting/dri2.c |    4 +---
 hw/xwin/winauth.c                     |   17 +++--------------
 record/record.c                       |    1 -
 render/picture.c                      |    3 +++
 xfixes/cursor.c                       |    4 +---
 9 files changed, 27 insertions(+), 37 deletions(-)

New commits:
commit 2be527b1d4ce2b0412c4484539a8c9607645ec6d
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:34 2016 +0100

    xfixes: avoid double free if AddResource fails
    
    pChc is already freed through CursorFreeHideCount →
    deleteCursorHideCount.
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 5619aad..10f9b23 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -774,10 +774,8 @@ createCursorHideCount(ClientPtr pClient, ScreenPtr pScreen)
      * Create a resource for this element so it can be deleted
      * when the client goes away.
      */
-    if (!AddResource(pChc->resource, CursorHideCountType, (void *) pChc)) {
-        free(pChc);
+    if (!AddResource(pChc->resource, CursorHideCountType, (void *) pChc))
         return BadAlloc;
-    }
 
     return Success;
 }
commit 4217db89ecd480fda2ee74fecba06c6713c2a0f0
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:33 2016 +0100

    render: free already allocated formats in PictureInit failure case
    
    Probably pointless, if this fails you're not likely to get far...
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/render/picture.c b/render/picture.c
index 6d9c9df..9e4036e 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -665,6 +665,9 @@ PictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     for (n = 0; n < nformats; n++) {
         if (!AddResource
             (formats[n].id, PictFormatType, (void *) (formats + n))) {
+            int i;
+            for (i = 0; i < n; i++)
+                FreeResource(formats[i].id, RT_NONE);
             free(formats);
             return FALSE;
         }
commit 054f80717812d4781741cd05393623fe6f6c627f
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:32 2016 +0100

    record: don't call RecordDeleteContext when AddResource fails
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/record/record.c b/record/record.c
index 1caf3f1..82bb060 100644
--- a/record/record.c
+++ b/record/record.c
@@ -1878,7 +1878,6 @@ ProcRecordCreateContext(ClientPtr client)
         return Success;
     }
     else {
-        RecordDeleteContext((void *) pContext, pContext->id);
         return BadAlloc;
     }
  bailout:
commit d0c1a5bc61a3d151f2234aa3820862f16c0f00c7
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:31 2016 +0100

    xwin: no need to free auth data if AddResource fails
    
    This is taken care of by SecurityDeleteAuthorization
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xwin/winauth.c b/hw/xwin/winauth.c
index 7efa1c0..7be7dca 100644
--- a/hw/xwin/winauth.c
+++ b/hw/xwin/winauth.c
@@ -114,7 +114,6 @@ GenerateAuthorization(unsigned name_length,
 Bool
 winGenerateAuthorization(void)
 {
-    Bool fFreeAuth = FALSE;
     SecurityAuthorizationPtr pAuth = NULL;
 
     /* Call OS layer to generate authorization key */
@@ -123,7 +122,7 @@ winGenerateAuthorization(void)
                                      0, NULL, &g_uiAuthDataLen, &g_pAuthData);
     if ((XID) ~0L == g_authId) {
         ErrorF("winGenerateAuthorization - GenerateAuthorization failed\n");
-        goto auth_bailout;
+        return FALSE;
     }
 
     else {
@@ -139,7 +138,7 @@ winGenerateAuthorization(void)
     if (!(pAuth)) {
         ErrorF("winGenerateAuthorization - Failed allocating "
                "SecurityAuthorizationPtr.\n");
-        goto auth_bailout;
+        return FALSE;
     }
 
     /* Fill in the auth fields */
@@ -155,21 +154,11 @@ winGenerateAuthorization(void)
     /* Add the authorization to the server's auth list */
     if (!AddResource(g_authId, SecurityAuthorizationResType, pAuth)) {
         ErrorF("winGenerateAuthorization - AddResource failed for auth.\n");
-        fFreeAuth = TRUE;
-        goto auth_bailout;
+        return FALSE;
     }
-
-    /* Don't free the auth data, since it is still used internally */
-    pAuth = NULL;
 #endif
 
     return TRUE;
-
- auth_bailout:
-    if (fFreeAuth)
-        free(pAuth);
-
-    return FALSE;
 }
 
 /* Use our generated cookie for authentication */
commit acf263df81ad6813e0233033610fb44521cab1b4
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:30 2016 +0100

    modesetting: avoid double free if AddResource fails
    
    ms_dri2_frame_event_client_gone or ms_dri2_frame_event_drawable_gone
    already free the resource.
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 0fe420c..83cb3e0 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -97,10 +97,8 @@ ms_get_resource(XID id, RESTYPE type)
     if (resource == NULL)
         return NULL;
 
-    if (!AddResource(id, type, resource)) {
-        free(resource);
+    if (!AddResource(id, type, resource))
         return NULL;
-    }
 
     resource->id = id;
     resource->type = type;
commit 164753f158e78f615f903467bfd234d7c58244ef
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:29 2016 +0100

    dmx/glxProxy: don't free the glx pixmap twice if AddResource fails
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index ddcb981..a77d556 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -2010,11 +2010,8 @@ CreateGLXPixmap(__GLXclientState * cl,
         XFlush(dpy);
     }
 
-    if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
-        free(pGlxPixmap->be_xids);
-        free(pGlxPixmap);
+    if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap)))
         return BadAlloc;
-    }
 
     return Success;
 }
commit 59b9c3d5e4bf05aeaaac2ee4ea12c301a67aae2c
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:28 2016 +0100

    glx: don't call pGlxDraw->destroy() if AddResource fails
    
    AddResource will have called DrawableGone, which takes care of the
    destruction.
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 0416dac..6eb3541 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -544,7 +544,6 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client,
 
     /* since we are creating the drawablePrivate, drawId should be new */
     if (!AddResource(drawId, __glXDrawableRes, pGlxDraw)) {
-        pGlxDraw->destroy(pGlxDraw);
         *error = BadAlloc;
         return NULL;
     }
@@ -1239,20 +1238,16 @@ DoCreateGLXDrawable(ClientPtr client, __GLXscreen * pGlxScreen,
     if (pGlxDraw == NULL)
         return BadAlloc;
 
-    if (!AddResource(glxDrawableId, __glXDrawableRes, pGlxDraw)) {
-        pGlxDraw->destroy(pGlxDraw);
+    if (!AddResource(glxDrawableId, __glXDrawableRes, pGlxDraw))
         return BadAlloc;
-    }
 
     /*
      * Windows aren't refcounted, so track both the X and the GLX window
      * so we get called regardless of destruction order.
      */
     if (drawableId != glxDrawableId && type == GLX_DRAWABLE_WINDOW &&
-        !AddResource(pDraw->id, __glXDrawableRes, pGlxDraw)) {
-        pGlxDraw->destroy(pGlxDraw);
+        !AddResource(pDraw->id, __glXDrawableRes, pGlxDraw))
         return BadAlloc;
-    }
 
     return Success;
 }
commit ac97fb2b804809c39b12fe0032d96fb076657258
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:27 2016 +0100

    dri3: return an error if AddResource fails
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/dri3/dri3_request.c b/dri3/dri3_request.c
index 2b36221..35548b6 100644
--- a/dri3/dri3_request.c
+++ b/dri3/dri3_request.c
@@ -178,8 +178,8 @@ proc_dri3_pixmap_from_buffer(ClientPtr client)
         (*drawable->pScreen->DestroyPixmap) (pixmap);
         return rc;
     }
-    if (AddResource(stuff->pixmap, RT_PIXMAP, (void *) pixmap))
-        return Success;
+    if (!AddResource(stuff->pixmap, RT_PIXMAP, (void *) pixmap))
+        return BadAlloc;
 
     return Success;
 }
commit 119d5c0e2f800737c949ef760c5fe25d963200bf
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Mar 7 23:20:26 2016 +0100

    xvmc: Fix unchecked AddResource
    
    Reviewed-by: Rémi Cardona <remi at gentoo.org>
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index 64eda92..7565c17 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -253,6 +253,10 @@ ProcXvMCCreateContext(ClientPtr client)
         free(pContext);
         return result;
     }
+    if (!AddResource(pContext->context_id, XvMCRTContext, pContext)) {
+        free(data);
+        return BadAlloc;
+    }
 
     rep = (xvmcCreateContextReply) {
         .type = X_Reply,
@@ -266,7 +270,6 @@ ProcXvMCCreateContext(ClientPtr client)
     WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
     if (dwords)
         WriteToClient(client, dwords << 2, data);
-    AddResource(pContext->context_id, XvMCRTContext, pContext);
 
     free(data);
 
@@ -329,6 +332,11 @@ ProcXvMCCreateSurface(ClientPtr client)
         free(pSurface);
         return result;
     }
+    if (!AddResource(pSurface->surface_id, XvMCRTSurface, pSurface)) {
+        free(data);
+        return BadAlloc;
+    }
+
     rep = (xvmcCreateSurfaceReply) {
         .type = X_Reply,
         .sequenceNumber = client->sequence,
@@ -338,7 +346,6 @@ ProcXvMCCreateSurface(ClientPtr client)
     WriteToClient(client, sizeof(xvmcCreateSurfaceReply), &rep);
     if (dwords)
         WriteToClient(client, dwords << 2, data);
-    AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
 
     free(data);
 
@@ -445,6 +452,11 @@ ProcXvMCCreateSubpicture(ClientPtr client)
         free(pSubpicture);
         return result;
     }
+    if (!AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture)) {
+        free(data);
+        return BadAlloc;
+    }
+
     rep = (xvmcCreateSubpictureReply) {
         .type = X_Reply,
         .sequenceNumber = client->sequence,
@@ -462,7 +474,6 @@ ProcXvMCCreateSubpicture(ClientPtr client)
     WriteToClient(client, sizeof(xvmcCreateSubpictureReply), &rep);
     if (dwords)
         WriteToClient(client, dwords << 2, data);
-    AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
 
     free(data);
 


More information about the xorg-commit mailing list