diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2010-01-15 20:13:20 +0000 |
---|---|---|
committer | Jakob Bornecrantz <jakob@vmware.com> | 2010-01-15 20:13:20 +0000 |
commit | 2959266188dd564975503d74e24b55013f58f861 (patch) | |
tree | 62589f2cf5d276b994910944dfa81de93a127081 /libkms | |
parent | 320811b282d7f57b364f8414e2e7b714f89b0503 (diff) |
libkms: Fix multiple map unmap in vmwgfx and add comment in intel
Diffstat (limited to 'libkms')
-rw-r--r-- | libkms/intel.c | 5 | ||||
-rw-r--r-- | libkms/vmwgfx.c | 20 |
2 files changed, 15 insertions, 10 deletions
diff --git a/libkms/intel.c b/libkms/intel.c index 784ee7b6..670494e7 100644 --- a/libkms/intel.c +++ b/libkms/intel.c @@ -220,8 +220,11 @@ intel_bo_destroy(struct kms_bo *_bo) struct drm_gem_close arg; int ret; - if (bo->base.ptr) + if (bo->base.ptr) { + /* XXX Sanity check map_count */ munmap(bo->base.ptr, bo->base.size); + bo->base.ptr = NULL; + } memset(&arg, 0, sizeof(arg)); arg.handle = bo->base.handle; diff --git a/libkms/vmwgfx.c b/libkms/vmwgfx.c index 5030b7e3..bcbc240a 100644 --- a/libkms/vmwgfx.c +++ b/libkms/vmwgfx.c @@ -160,16 +160,17 @@ vmwgfx_bo_map(struct kms_bo *_bo, void **out) struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo; void *map; - if (!bo->map_count) { - map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, - MAP_SHARED, bo->base.kms->fd, bo->map_handle); - - if (!map) - return -ENOMEM; - - bo->base.ptr = map; + if (bo->base.ptr) { + bo->map_count++; + *out = bo->base.ptr; + return 0; } + map = mmap(NULL, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, bo->map_handle); + if (map == MAP_FAILED) + return -errno; + + bo->base.ptr = map; bo->map_count++; *out = bo->base.ptr; @@ -190,7 +191,8 @@ vmwgfx_bo_destroy(struct kms_bo *_bo) struct vmwgfx_bo *bo = (struct vmwgfx_bo *)_bo; struct drm_vmw_unref_dmabuf_arg arg; - if (bo->map_count) { + if (bo->base.ptr) { + /* XXX Sanity check map_count */ munmap(bo->base.ptr, bo->base.size); bo->base.ptr = NULL; } |