diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2018-02-14 18:13:16 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2018-02-15 17:23:02 +0100 |
commit | 8a55e66bfd77dcb2553a43e86215b9d3c87b03f0 (patch) | |
tree | 093b67c80f2391de158ba101a9b38d5044dd810e /src/radeon_kms.c | |
parent | 703cbb7177c6f69264836e975c1921e552fd60a4 (diff) |
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>
Diffstat (limited to 'src/radeon_kms.c')
-rw-r--r-- | src/radeon_kms.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 25b889a6..6b1dc38b 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 * |