Don't use RADEONEntPriv in RADEONFreeRec

It crashes if info == NULL.

(Ported from amdgpu commits fb8444e731765588c0ff1e9053c1c7b73f5f0907 &
 cfccf4c4e7e5c73fe4040fabeb1b43283cf29b33)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Michel Dänzer
2018-02-14 18:13:16 +01:00
committed by Michel Dänzer
parent 703cbb7177
commit 8a55e66bfd

View File

@@ -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 *