From b742f7391351696d51adbfdf2c7b9b1a7bd5ef7d Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 4 Jun 2021 15:15:30 -0500 Subject: [PATCH] intel/isl: Fix isl_format_is_valid The format enum space isn't necessarily contiguous so we can't assume that if it's in the table it's valid. We need to check something. Fixes: ed6e586562f4 "intel: properly constify isl_format_layouts" Reviewed-by: Adam Jackson Part-of: --- src/intel/isl/gen_format_layout.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/intel/isl/gen_format_layout.py b/src/intel/isl/gen_format_layout.py index 540c0537e27..9b23414f29e 100644 --- a/src/intel/isl/gen_format_layout.py +++ b/src/intel/isl/gen_format_layout.py @@ -105,7 +105,12 @@ isl_format_is_valid(enum isl_format format) { if (format >= sizeof(isl_format_layouts) / sizeof(isl_format_layouts[0])) return false; - return true; + + /* Only ISL_FORMAT_R32G32B32A32_FLOAT == 0 but that's a valid format. + * For all others, if this doesn't match then the entry in the table + * must not exist. + */ + return isl_format_layouts[format].format == format; } enum isl_format