v3dv: duplicate key for texel_buffer cache

We can't use the local variable key to insert in the hashtable, as the
key needs to be persistent for future searches.

This makes a copy of the key in the pipeline, which is kept persistent
in the hashtable.

This fixes a stack-buffer-overflow.

Backport-to: 25.0
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33630>
This commit is contained in:
Juan A. Suarez Romero 2025-02-19 19:50:36 +01:00 committed by Marge Bot
parent 5980d60cf1
commit eb8017ca68

View file

@ -2535,8 +2535,9 @@ get_copy_texel_buffer_pipeline(
goto fail;
if (device->instance->meta_cache_enabled) {
memcpy((*pipeline)->key, key, sizeof((*pipeline)->key));
_mesa_hash_table_insert(device->meta.texel_buffer_copy.cache[image_type],
key, *pipeline);
&(*pipeline)->key, *pipeline);
mtx_unlock(&device->meta.mtx);
} else {
v3dv_cmd_buffer_add_private_obj(