drm/xe: Fix array bounds check for queries

Queries are 0-indexed, so a query with value N is invalid if the
ARRAY_SIZE is N. Modify the check to account for that.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
Umesh Nerlige Ramappa 2023-09-20 15:29:21 -04:00 committed by Rodrigo Vivi
parent 6de492ae5f
commit fd47ded237

View File

@ -381,7 +381,7 @@ int xe_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
XE_IOCTL_DBG(xe, query->reserved[0] || query->reserved[1]))
return -EINVAL;
if (XE_IOCTL_DBG(xe, query->query > ARRAY_SIZE(xe_query_funcs)))
if (XE_IOCTL_DBG(xe, query->query >= ARRAY_SIZE(xe_query_funcs)))
return -EINVAL;
idx = array_index_nospec(query->query, ARRAY_SIZE(xe_query_funcs));