[PATCH 1/3] omap: Fix missing usage count decrease in OMAPDRI2DestroyBuffer

Tony Lindgren tony at atomide.com
Tue Feb 4 18:33:58 UTC 2020


Commit 0bdd370ab720 ("dri2: hold extra buffer ref during swap") started
increasing pPixmap->refcnt for DRI2BufferFrontLeft, but that gets never
decremented in OMAPDRI2DestroyBuffer.

Let's fix the issue by pairing the increment with a decrement in
OMAPDRI2DestroyBuffer. Otherwise we get a segfault after rotating an
sgx accelerated opengl es app and then terminating it.

Fixes: 0bdd370ab720 ("dri2: hold extra buffer ref during swap")
Cc: Ivaylo Dimitrov <ivo.g.dimitrov.75 at gmail.com>
Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Cc: Matthijs van Duin <matthijsvanduin at gmail.com>
Cc: Merlijn Wajer <merlijn at wizzup.org>
Cc: Rob Clark <robdclark at chromium.org>
Cc: Sebastian Reichel <sre at kernel.org>
Cc: Tomi Valkeinen <tomi.valkeinen at ti.com>
Signed-off-by: Tony Lindgren <tony at atomide.com>
---
 src/omap_dri2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/omap_dri2.c b/src/omap_dri2.c
--- a/src/omap_dri2.c
+++ b/src/omap_dri2.c
@@ -316,7 +316,11 @@ OMAPDRI2DestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
 		pPriv->pThirdBuffer = NULL;
 	}
 
-	pScreen->DestroyPixmap(buf->pPixmap);
+	/* Pair refcount increment done in OMAPDRI2CreateBuffer */
+	if (buffer->attachment == DRI2BufferFrontLeft && buf->pPixmap->refcnt)
+		buf->pPixmap->refcnt--;
+	else
+		pScreen->DestroyPixmap(buf->pPixmap);
 
 	free(buf);
 }
-- 
2.25.0


More information about the xorg-devel mailing list