lima: fix array limit in texture mipmap descriptor

Fix an off-by-one error in the texture mipmap descriptor code.
This fixes a segfault in applications that acutually use all
available mipmap levels.

Fixes: a3f827319f ("lima: add genxml for texture descriptor")

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36300>
This commit is contained in:
Erico Nunes
2025-07-22 23:00:02 +02:00
committed by Marge Bot
parent e847d9920c
commit 92213f647e

View File

@@ -87,7 +87,7 @@ lima_texture_desc_set_res(struct lima_context *ctx, struct LIMA_TEXTURE_DESCRIPT
&desc->mip_10};
int max_mips = MIN2(last_level - first_level, sizeof(mips) / sizeof(mips[0]));
int max_mips = MIN2(last_level - first_level, ARRAY_SIZE(mips) - 1);
for (int i = 0; i <= max_mips; i++) {
*mips[i] = base_va + lima_res->levels[first_level + i].offset;