diff options
author | Michel Dänzer <daenzer@vmware.com> | 2011-01-18 10:23:41 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2011-01-18 10:54:58 +0100 |
commit | 6548bb9836253c586023ffe5ad1497ddabaa50fc (patch) | |
tree | 44ce11e60b9a94215505ea68a722bec423f2735a /src | |
parent | edc3496b55577ee8509ddd9188e6f2bcdf7169a1 (diff) |
Fix KMS textured video leaks (bug #33193).
v2: Fix radeon_legacy_free_memory() argument type error pointed out by
Marton Balint, refactor video memory freeing logic into helper function.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=33193 .
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon_legacy_memory.c | 3 | ||||
-rw-r--r-- | src/radeon_textured_video.c | 5 | ||||
-rw-r--r-- | src/radeon_video.c | 32 | ||||
-rw-r--r-- | src/radeon_video.h | 1 |
4 files changed, 26 insertions, 15 deletions
diff --git a/src/radeon_legacy_memory.c b/src/radeon_legacy_memory.c index 3e75291f..32d8c797 100644 --- a/src/radeon_legacy_memory.c +++ b/src/radeon_legacy_memory.c @@ -26,6 +26,9 @@ radeon_legacy_allocate_memory(ScrnInfoPtr pScrn, if (info->cs) { struct radeon_bo *video_bo; + if (*mem_struct) + radeon_legacy_free_memory(pScrn, *mem_struct); + video_bo = radeon_bo_open(info->bufmgr, 0, size, RADEON_GPU_PAGE_SIZE, domain, 0); *mem_struct = video_bo; diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c index 36bcb562..163ee48e 100644 --- a/src/radeon_textured_video.c +++ b/src/radeon_textured_video.c @@ -314,9 +314,8 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn, size = dstPitch * dst_height + 2 * dstPitch2 * ((dst_height + 1) >> 1); size = RADEON_ALIGN(size, hw_align); - if (pPriv->video_memory != NULL && size != pPriv->size) { - radeon_legacy_free_memory(pScrn, pPriv->video_memory); - pPriv->video_memory = NULL; + if (size != pPriv->size) { + RADEONFreeVideoMemory(pScrn, pPriv); } if (pPriv->video_memory == NULL) { diff --git a/src/radeon_video.c b/src/radeon_video.c index 0bb5ab3b..4355f8bb 100644 --- a/src/radeon_video.c +++ b/src/radeon_video.c @@ -1646,6 +1646,23 @@ RADEONSetupImageVideo(ScreenPtr pScreen) } void +RADEONFreeVideoMemory(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + if (pPriv->video_memory != NULL) { + radeon_legacy_free_memory(pScrn, pPriv->video_memory); + pPriv->video_memory = NULL; + + if (info->cs && pPriv->textured) { + pPriv->src_bo[0] = NULL; + radeon_legacy_free_memory(pScrn, (void*)&pPriv->src_bo[1]); + pPriv->src_bo[1] = NULL; + } + } +} + +void RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) { RADEONInfoPtr info = RADEONPTR(pScrn); @@ -1654,10 +1671,7 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) if (pPriv->textured) { if (cleanup) { - if (pPriv->video_memory != NULL) { - radeon_legacy_free_memory(pScrn, pPriv->video_memory); - pPriv->video_memory = NULL; - } + RADEONFreeVideoMemory(pScrn, pPriv); } return; } @@ -1679,10 +1693,7 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup) if(pPriv->uda1380 != NULL) xf86_uda1380_mute(pPriv->uda1380, TRUE); if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv); } - if (pPriv->video_memory != NULL) { - radeon_legacy_free_memory(pScrn, pPriv->video_memory); - pPriv->video_memory = NULL; - } + RADEONFreeVideoMemory(pScrn, pPriv); pPriv->videoStatus = 0; } else { if(pPriv->videoStatus & CLIENT_VIDEO_ON) { @@ -3152,10 +3163,7 @@ RADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time now) } } else { /* FREE_TIMER */ if(pPriv->freeTime < now) { - if (pPriv->video_memory != NULL) { - radeon_legacy_free_memory(pScrn, pPriv->video_memory); - pPriv->video_memory = NULL; - } + RADEONFreeVideoMemory(pScrn, pPriv); pPriv->videoStatus = 0; info->VideoTimerCallback = NULL; } diff --git a/src/radeon_video.h b/src/radeon_video.h index ab0c433e..c315bbb5 100644 --- a/src/radeon_video.h +++ b/src/radeon_video.h @@ -150,6 +150,7 @@ void RADEONVIP_reset(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv); int RADEONSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer); int RADEONGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer); +void RADEONFreeVideoMemory(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv); void RADEONStopVideo(ScrnInfoPtr, pointer, Bool); void RADEONQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short, unsigned int *, unsigned int *, pointer); |