anv: reuse object string for RMV token

The current code is not handling the potential NULL pointer in
VkDebugUtilsObjectNameInfoEXT::pObjectName

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: e1b9a6e4f3 ("anv: initial RMV support")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30516>
(cherry picked from commit c6bf1f02c4)
This commit is contained in:
Lionel Landwerlin 2024-08-05 16:09:21 +03:00 committed by Eric Engestrom
parent 576e9ff953
commit 71125139f1
2 changed files with 6 additions and 11 deletions

View file

@ -4044,7 +4044,7 @@
"description": "anv: reuse object string for RMV token",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "e1b9a6e4f3c1702d68866bec2799b1216812595a",
"notes": null

View file

@ -100,19 +100,14 @@ VkResult anv_rmv_SetDebugUtilsObjectNameEXT(
return VK_SUCCESS;
}
size_t name_len = strlen(pNameInfo->pObjectName);
char *name_buf = malloc(name_len + 1);
if (!name_buf) {
/*
* Silently fail, so that applications may still continue if possible.
*/
return VK_SUCCESS;
}
strcpy(name_buf, pNameInfo->pObjectName);
struct vk_object_base *object =
vk_object_base_from_u64_handle(pNameInfo->objectHandle,
pNameInfo->objectType);
simple_mtx_lock(&device->vk.memory_trace_data.token_mtx);
struct vk_rmv_userdata_token token;
token.name = name_buf;
token.name = vk_strdup(&device->vk.alloc, object->object_name,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
token.resource_id = vk_rmv_get_resource_id_locked(&device->vk, pNameInfo->objectHandle);
vk_rmv_emit_token(&device->vk.memory_trace_data, VK_RMV_TOKEN_TYPE_USERDATA, &token);