[PATCH xf86-video-ati 2/4] Don't use RADEONEntPriv in RADEONFreeRec

Michel Dänzer michel at daenzer.net
Wed Feb 14 17:49:28 UTC 2018


From: Michel Dänzer <michel.daenzer at amd.com>

It crashes if info == NULL.

(Ported from amdgpu commits fb8444e731765588c0ff1e9053c1c7b73f5f0907 &
 cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33)

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/radeon_kms.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 25b889a67..6b1dc38b0 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -194,18 +194,33 @@ static Bool RADEONGetRec(ScrnInfoPtr pScrn)
 /* Free our private RADEONInfoRec */
 static void RADEONFreeRec(ScrnInfoPtr pScrn)
 {
+    DevUnion *pPriv;
     RADEONEntPtr pRADEONEnt;
     RADEONInfoPtr  info;
+    EntityInfoPtr pEnt;
 
-    if (!pScrn || !pScrn->driverPrivate) return;
+    if (!pScrn)
+	return;
 
     info = RADEONPTR(pScrn);
+    if (info) {
+	if (info->fbcon_pixmap)
+	    pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
 
-    if (info->fbcon_pixmap)
-	pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
+	if (info->accel_state) {
+	    free(info->accel_state);
+	    info->accel_state = NULL;
+	}
 
-    pRADEONEnt = RADEONEntPriv(pScrn);
+	pEnt = info->pEnt;
+	free(pScrn->driverPrivate);
+	pScrn->driverPrivate = NULL;
+    } else {
+	pEnt = xf86GetEntityInfo(pScrn->entityList[pScrn->numEntities - 1]);
+    }
 
+    pPriv = xf86GetEntityPrivate(pEnt->index, gRADEONEntityIndex);
+    pRADEONEnt = pPriv->ptr;
     if (pRADEONEnt->fd > 0) {
         DevUnion *pPriv;
         RADEONEntPtr pRADEONEnt;
@@ -225,14 +240,7 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn)
         }
     }
 
-    if (info->accel_state) {
-	free(info->accel_state);
-	info->accel_state = NULL;
-    }
-
-    free(info->pEnt);
-    free(pScrn->driverPrivate);
-    pScrn->driverPrivate = NULL;
+    free(pEnt);
 }
 
 static void *
-- 
2.16.1



More information about the amd-gfx mailing list