mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 04:40:09 +01:00
pvr: reset the pds info map entries pointer to avoid double free
Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
parent
2424b31870
commit
e2d466f06c
1 changed files with 29 additions and 16 deletions
|
|
@ -251,6 +251,17 @@ static inline size_t pvr_pds_get_max_vertex_program_const_map_size_in_bytes(
|
||||||
sizeof(struct pvr_const_map_entry_doutu_address));
|
sizeof(struct pvr_const_map_entry_doutu_address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
pvr_pds_free_pds_info_map_entries(struct pvr_device *const device,
|
||||||
|
const VkAllocationCallbacks *const allocator,
|
||||||
|
struct pvr_const_map_entry **const entries)
|
||||||
|
{
|
||||||
|
if (entries && *entries) {
|
||||||
|
vk_free2(&device->vk.alloc, allocator, *entries);
|
||||||
|
*entries = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VkResult pvr_pds_vertex_attrib_program_create_and_upload(
|
static VkResult pvr_pds_vertex_attrib_program_create_and_upload(
|
||||||
struct pvr_device *const device,
|
struct pvr_device *const device,
|
||||||
const VkAllocationCallbacks *const allocator,
|
const VkAllocationCallbacks *const allocator,
|
||||||
|
|
@ -313,8 +324,8 @@ static VkResult pvr_pds_vertex_attrib_program_create_and_upload(
|
||||||
|
|
||||||
assert(info->code_size_in_dwords <= code_size_in_dwords);
|
assert(info->code_size_in_dwords <= code_size_in_dwords);
|
||||||
|
|
||||||
/* FIXME: Add a vk_realloc2() ? */
|
new_entries = vk_realloc2(&device->vk.alloc,
|
||||||
new_entries = vk_realloc((!allocator) ? &device->vk.alloc : allocator,
|
allocator,
|
||||||
info->entries,
|
info->entries,
|
||||||
info->entries_written_size_in_bytes,
|
info->entries_written_size_in_bytes,
|
||||||
8,
|
8,
|
||||||
|
|
@ -348,7 +359,7 @@ err_free_staging_buffer:
|
||||||
vk_free2(&device->vk.alloc, allocator, staging_buffer);
|
vk_free2(&device->vk.alloc, allocator, staging_buffer);
|
||||||
|
|
||||||
err_free_entries:
|
err_free_entries:
|
||||||
vk_free2(&device->vk.alloc, allocator, info->entries);
|
pvr_pds_free_pds_info_map_entries(device, allocator, &info->entries);
|
||||||
|
|
||||||
err_out:
|
err_out:
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -360,7 +371,7 @@ static inline void pvr_pds_vertex_attrib_program_destroy(
|
||||||
struct pvr_pds_attrib_program *const program)
|
struct pvr_pds_attrib_program *const program)
|
||||||
{
|
{
|
||||||
pvr_bo_suballoc_free(program->program.pvr_bo);
|
pvr_bo_suballoc_free(program->program.pvr_bo);
|
||||||
vk_free2(&device->vk.alloc, allocator, program->info.entries);
|
pvr_pds_free_pds_info_map_entries(device, allocator, &program->info.entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is a const pointer to an array of pvr_pds_attrib_program structs.
|
/* This is a const pointer to an array of pvr_pds_attrib_program structs.
|
||||||
|
|
@ -660,8 +671,8 @@ static VkResult pvr_pds_descriptor_program_create_and_upload(
|
||||||
|
|
||||||
assert(pds_info->code_size_in_dwords <= code_size_in_dwords);
|
assert(pds_info->code_size_in_dwords <= code_size_in_dwords);
|
||||||
|
|
||||||
/* FIXME: use vk_realloc2() ? */
|
new_entries = vk_realloc2(&device->vk.alloc,
|
||||||
new_entries = vk_realloc((!allocator) ? &device->vk.alloc : allocator,
|
allocator,
|
||||||
pds_info->entries,
|
pds_info->entries,
|
||||||
pds_info->entries_written_size_in_bytes,
|
pds_info->entries_written_size_in_bytes,
|
||||||
8,
|
8,
|
||||||
|
|
@ -695,7 +706,7 @@ err_free_staging_buffer:
|
||||||
vk_free2(&device->vk.alloc, allocator, staging_buffer);
|
vk_free2(&device->vk.alloc, allocator, staging_buffer);
|
||||||
|
|
||||||
err_free_entries:
|
err_free_entries:
|
||||||
vk_free2(&device->vk.alloc, allocator, pds_info->entries);
|
pvr_pds_free_pds_info_map_entries(device, allocator, &pds_info->entries);
|
||||||
|
|
||||||
err_free_static_consts:
|
err_free_static_consts:
|
||||||
pvr_bo_suballoc_free(descriptor_state->static_consts);
|
pvr_bo_suballoc_free(descriptor_state->static_consts);
|
||||||
|
|
@ -712,7 +723,9 @@ static void pvr_pds_descriptor_program_destroy(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pvr_bo_suballoc_free(descriptor_state->pds_code.pvr_bo);
|
pvr_bo_suballoc_free(descriptor_state->pds_code.pvr_bo);
|
||||||
vk_free2(&device->vk.alloc, allocator, descriptor_state->pds_info.entries);
|
pvr_pds_free_pds_info_map_entries(device,
|
||||||
|
allocator,
|
||||||
|
&descriptor_state->pds_info.entries);
|
||||||
pvr_bo_suballoc_free(descriptor_state->static_consts);
|
pvr_bo_suballoc_free(descriptor_state->static_consts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue