summaryrefslogtreecommitdiff
path: root/src/legacy/i810/i810_dri.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-06-04 12:04:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-06-04 12:04:30 +0100
commit880ec2c9a56d3de33c7fbbfa4c043082fbcf7a78 (patch)
tree57529a923224079802b1ffe0adfe8032fe3a17ae /src/legacy/i810/i810_dri.c
parent7424ea7dd08e304baa4efa09e887b833737ac9f6 (diff)
legacy/i810: Reorder DRI teardown code to avoid potential NULL derefs
Reported-by: Zdenek Kabelac <zkabelac@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/legacy/i810/i810_dri.c')
-rw-r--r--src/legacy/i810/i810_dri.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/legacy/i810/i810_dri.c b/src/legacy/i810/i810_dri.c
index 28a3b919..a98ed436 100644
--- a/src/legacy/i810/i810_dri.c
+++ b/src/legacy/i810/i810_dri.c
@@ -898,30 +898,42 @@ I810DRICloseScreen(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
I810Ptr pI810 = I810PTR(pScrn);
- I810DRIPtr pI810DRI = (I810DRIPtr) pI810->pDRIInfo->devPrivate;
- if (pI810DRI->irq) {
- drmCtlUninstHandler(pI810->drmSubFD);
- pI810DRI->irq = 0;
- }
+ if (pI810->pDRIInfo) {
+ I810DRIPtr pI810DRI = (I810DRIPtr) pI810->pDRIInfo->devPrivate;
+
+ if (pI810DRI) {
+ if (pI810DRI->irq) {
+ drmCtlUninstHandler(pI810->drmSubFD);
+ pI810DRI->irq = 0;
+ }
- I810CleanupDma(pScrn);
+ free(pI810->pDRIInfo->devPrivate);
+ pI810->pDRIInfo->devPrivate = NULL;
+ }
+
+ I810CleanupDma(pScrn);
+
+ DRICloseScreen(pScreen);
+ DRIDestroyInfoRec(pI810->pDRIInfo);
+ pI810->pDRIInfo = NULL;
+ }
if (pI810->dcacheHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->dcacheHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->dcacheHandle);
if (pI810->backHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->backHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->backHandle);
if (pI810->zHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->zHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->zHandle);
if (pI810->cursorHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->cursorHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->cursorHandle);
if (pI810->xvmcHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->xvmcHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->xvmcHandle);
if (pI810->sysmemHandle!=DRM_AGP_NO_HANDLE)
- drmAgpFree(pI810->drmSubFD, pI810->sysmemHandle);
+ drmAgpFree(pI810->drmSubFD, pI810->sysmemHandle);
if (pI810->agpAcquired == TRUE)
- drmAgpRelease(pI810->drmSubFD);
+ drmAgpRelease(pI810->drmSubFD);
pI810->backHandle = DRM_AGP_NO_HANDLE;
pI810->zHandle = DRM_AGP_NO_HANDLE;
@@ -930,17 +942,6 @@ I810DRICloseScreen(ScreenPtr pScreen)
pI810->sysmemHandle = DRM_AGP_NO_HANDLE;
pI810->agpAcquired = FALSE;
pI810->dcacheHandle = DRM_AGP_NO_HANDLE;
-
- DRICloseScreen(pScreen);
-
- if (pI810->pDRIInfo) {
- if (pI810->pDRIInfo->devPrivate) {
- free(pI810->pDRIInfo->devPrivate);
- pI810->pDRIInfo->devPrivate = NULL;
- }
- DRIDestroyInfoRec(pI810->pDRIInfo);
- pI810->pDRIInfo = NULL;
- }
}
static Bool