Mesa (master): anv: bo_cache: allow importing a BO larger than needed

Lionel Landwerlin llandwerlin at kemper.freedesktop.org
Wed Oct 11 21:30:06 UTC 2017


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Wed Oct 11 17:21:53 2017 +0100

anv: bo_cache: allow importing a BO larger than needed

It's not a problem if a BO has been allocated larger than we need it
to be.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102940
Fixes: 818b857914 ("anv: Use the BO cache for DeviceMemory allocations")
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Cc: mesa-stable at lists.freedesktop.org

---

 src/intel/vulkan/anv_allocator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index be750adeb5..0f123563f7 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -1302,7 +1302,7 @@ anv_bo_cache_import(struct anv_device *device,
        * this sort of attack but only if it can trust the buffer size.
        */
       off_t import_size = lseek(fd, 0, SEEK_END);
-      if (import_size == (off_t)-1 || import_size != size) {
+      if (import_size == (off_t)-1 || import_size < size) {
          anv_gem_close(device, gem_handle);
          pthread_mutex_unlock(&cache->mutex);
          return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);




More information about the mesa-commit mailing list