From a4d1bc43d4d10e2ca1e512c1010e962c587d6c16 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 20 Mar 2013 17:13:44 +0100 Subject: Cleanup drmmode in CloseScreen. Prevents a use-after-free. Signed-off-by: Maarten Lankhorst --- src/drmmode_display.c | 14 ++++++++++++++ src/drmmode_display.h | 1 + src/radeon_kms.c | 1 + 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 0d738563..d09c69ce 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1584,6 +1584,20 @@ void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode) } } +void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +{ + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (pRADEONEnt->fd_wakeup_registered == serverGeneration && + info->dri2.pKernelDRMVersion->version_minor >= 4) { + RemoveGeneralSocket(drmmode->fd); + RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, + drm_wakeup_handler, drmmode); + } +} + + Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr) { drmmode->bufmgr = bufmgr; diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 45c33cb3..b63ec8eb 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -99,6 +99,7 @@ typedef struct { extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp); extern void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index e2474670..f997d8a5 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1065,6 +1065,7 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL) drmDropMaster(info->dri2.drm_fd); + drmmode_fini(pScrn, &info->drmmode); if (info->dri2.enabled) radeon_dri2_close_screen(pScreen); drmClose(info->dri2.drm_fd); -- cgit v1.2.3