summaryrefslogtreecommitdiff
path: root/lib/i915/intel_memory_region.c
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2021-07-08 13:25:52 +0100
committerMatthew Auld <matthew.auld@intel.com>2021-07-26 11:00:47 +0100
commit08c084830e1b30409df513f94ccdce84f950ced0 (patch)
tree7f50180fea764b7b556f90ed34142c24bc7b7dd1 /lib/i915/intel_memory_region.c
parent34ff2cf2bc352dce691593db803389fe0eb2be03 (diff)
lib/intel_memory_region: verify item.length
If the regions query fails then the error will be encoded in the item.length, while the ioctl will still return success. Reported-by: Ville Syrjala <ville.syrjala@linux.intel.com> Signed-off-by: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
Diffstat (limited to 'lib/i915/intel_memory_region.c')
-rw-r--r--lib/i915/intel_memory_region.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/i915/intel_memory_region.c b/lib/i915/intel_memory_region.c
index 144ae12c..e1e210f2 100644
--- a/lib/i915/intel_memory_region.c
+++ b/lib/i915/intel_memory_region.c
@@ -119,6 +119,13 @@ struct drm_i915_query_memory_regions *gem_get_query_memory_regions(int fd)
memset(&item, 0, sizeof(item));
item.query_id = DRM_I915_QUERY_MEMORY_REGIONS;
i915_query_items(fd, &item, 1);
+ /*
+ * Any DRM_I915_QUERY_MEMORY_REGIONS specific errors are encoded in the
+ * item.length, even though the ioctl might still return success.
+ */
+ igt_assert_f(item.length > 0,
+ "DRM_I915_QUERY_MEMORY_REGIONS failed with %d\n",
+ item.length);
query_info = calloc(1, item.length);