diff options
author | Eric Anholt <eric@anholt.net> | 2008-06-06 17:13:16 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-06-06 17:13:16 -0700 |
commit | 500c81d194115fb3c4b97d742519689478eeb4e8 (patch) | |
tree | be896c14a45c91e05ff85bd261d0bd5b09269943 | |
parent | 6cd0ef06a6c2bdcede166d9a2d0434e58e4a01f2 (diff) |
[gem] Don't forget to munmap in the non-bo-reuse object-freeing case.
-rw-r--r-- | libdrm/intel/intel_bufmgr_gem.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index 6504ad6e..a65ae982 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -379,6 +379,28 @@ dri_gem_bo_reference(dri_bo *bo) } static void +dri_gem_bo_free(dri_bo *bo) +{ + dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)bo->bufmgr; + dri_bo_gem *bo_gem = (dri_bo_gem *)bo; + struct drm_gem_close close; + int ret; + + if (bo_gem->mapped) + munmap (bo_gem->virtual, bo_gem->bo.size); + + /* Close this object */ + close.handle = bo_gem->gem_handle; + ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close); + if (ret != 0) { + fprintf(stderr, + "DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n", + bo_gem->gem_handle, bo_gem->name, strerror(-ret)); + } + free(bo); +} + +static void dri_gem_bo_unreference(dri_bo *bo) { dri_bufmgr_gem *bufmgr_gem = (dri_bufmgr_gem *)bo->bufmgr; @@ -389,7 +411,6 @@ dri_gem_bo_unreference(dri_bo *bo) if (--bo_gem->refcount == 0) { struct dri_gem_bo_bucket *bucket; - int ret; if (bo_gem->relocs != NULL) { int i; @@ -422,17 +443,7 @@ dri_gem_bo_unreference(dri_bo *bo) bucket->tail = &bo_gem->next; bucket->num_entries++; } else { - struct drm_gem_close close; - - /* Close this object */ - close.handle = bo_gem->gem_handle; - ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close); - if (ret != 0) { - fprintf(stderr, - "DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n", - bo_gem->gem_handle, bo_gem->name, strerror(-ret)); - } - free(bo); + dri_gem_bo_free(bo); } return; @@ -591,26 +602,12 @@ dri_bufmgr_gem_destroy(dri_bufmgr *bufmgr) dri_bo_gem *bo_gem; while ((bo_gem = bucket->head) != NULL) { - struct drm_gem_close close; - int ret; - bucket->head = bo_gem->next; if (bo_gem->next == NULL) bucket->tail = &bucket->head; bucket->num_entries--; - if (bo_gem->mapped) - munmap (bo_gem->virtual, bo_gem->bo.size); - - /* Close this object */ - close.handle = bo_gem->gem_handle; - ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close); - if (ret != 0) { - fprintf(stderr, "DRM_IOCTL_GEM_CLOSE failed: %s\n", - strerror(-ret)); - } - - free(bo_gem); + dri_gem_bo_free(&bo_gem->bo); } } |