anv: bo_cache: allow importing a BO larger than needed
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 11 Oct 2017 16:21:53 +0000 (17:21 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 11 Oct 2017 21:29:55 +0000 (22:29 +0100)
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@intel.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
src/intel/vulkan/anv_allocator.c

index be750adeb5223919b797f09f2d72eed903e0a1aa..0f123563f79647dbcf93c05d074e29a8425c4cc1 100644 (file)
@@ -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);