Mesa (master): gallium/radeon: Fix potential address space loss in radeon_bomgr_force_va().

Michel Dänzer daenzer at kemper.freedesktop.org
Thu Aug 16 10:00:44 UTC 2012


Module: Mesa
Branch: master
Commit: 1f455ef5bc3c9711d9452dcc09fd849656ad8b33
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1f455ef5bc3c9711d9452dcc09fd849656ad8b33

Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Apr 26 12:10:02 2012 +0200

gallium/radeon: Fix potential address space loss in radeon_bomgr_force_va().

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

---

 src/gallium/winsys/radeon/drm/radeon_drm_bo.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 1bf22a7..79355af 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -268,18 +268,25 @@ static void radeon_bomgr_force_va(struct radeon_bomgr *mgr, uint64_t va, uint64_
         mgr->va_offset = va + size;
     } else {
         struct radeon_bo_va_hole *hole, *n;
-        uint64_t stmp, etmp;
+        uint64_t hole_end, va_end;
 
-        /* free all holes that fall into the range
-         * NOTE that we might lose virtual address space
+        /* Prune/free all holes that fall into the range
          */
         LIST_FOR_EACH_ENTRY_SAFE(hole, n, &mgr->va_holes, list) {
-            stmp = hole->offset;
-            etmp = stmp + hole->size;
-            if (va >= stmp && va < etmp) {
+            hole_end = hole->offset + hole->size;
+            va_end = va + size;
+            if (hole->offset >= va_end || hole_end <= va)
+                continue;
+            if (hole->offset >= va && hole_end <= va_end) {
                 list_del(&hole->list);
                 FREE(hole);
+                continue;
             }
+            if (hole->offset >= va)
+                hole->offset = va_end;
+            else
+                hole_end = va;
+            hole->size = hole_end - hole->offset;
         }
     }
     pipe_mutex_unlock(mgr->bo_va_mutex);




More information about the mesa-commit mailing list