Skip to content

Commit 19ea29d

Browse files
committed
Fix dereference after free when MEM_DEBUG_MSG is enabled
174 (Local) /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src/acl_mem.cpp:4479 UFM.DEREF.MIGHT (1:Critical) Analyze Object 'block_allocation' was dereferenced at line 4479 after being freed by calling 'acl_delete<acl_block_allocation_t>' at line 4475 * acl_mem.cpp:4450: block_allocation==nullptr is false * acl_mem.cpp:4456: mem->reserved_allocations[physical_device_id] .size() >target_mem_id is true * acl_mem.cpp:4457: mem->reserved_allocations[physical_device_id] [target_mem_id] ==0 is true * acl_mem.cpp:4458: mem->reserved_allocations_count[physical_device_id] [target_mem_id] ==0 is true * acl_mem.cpp:4470: result is false * acl_mem.cpp:4475: 'block_allocation' is freed by calling 'acl_delete<acl_block_allocation_t>'. * acl_support.h:31: Tracking 't'. * acl_support.h:31: 't' is freed by calling 'delete'. * acl_mem.cpp:4479: Freed pointer 'block_allocation' is used by calling 'printf'. Signed-off-by: Peter Colberg <[email protected]>
1 parent df5aa45 commit 19ea29d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/acl_mem.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,14 +4467,15 @@ cl_int acl_reserve_buffer_block(cl_mem mem, acl_mem_region_t *region,
44674467
result = copy_image_metadata(mem);
44684468
}
44694469

4470-
if (result) {
4471-
mem->reserved_allocations[physical_device_id][target_mem_id] =
4472-
block_allocation;
4473-
block_allocation->mem_obj = mem;
4474-
} else {
4470+
if (!result) {
44754471
acl_delete(block_allocation);
4472+
return result;
44764473
}
44774474

4475+
mem->reserved_allocations[physical_device_id][target_mem_id] =
4476+
block_allocation;
4477+
block_allocation->mem_obj = mem;
4478+
44784479
#ifdef MEM_DEBUG_MSG
44794480
printf("acl_reserve_buffer_block finished block_allocation:%zx, range:%zx - "
44804481
"%zx \n",

0 commit comments

Comments
 (0)