Skip to content

Commit f171b99

Browse files
committed
Fixed coverity issue in acl_mem.cpp: Memory leak
(Line 4172) Missing free for a malloc object before returning, same with (line 4183)
1 parent 3c7971d commit f171b99

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/acl_mem.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,15 +2775,15 @@ CL_API_ENTRY void *CL_API_CALL clEnqueueMapImageIntelFPGA(
27752775
*image_slice_pitch = 0;
27762776
} else {
27772777
BAIL_INFO(CL_INVALID_VALUE, command_queue->context,
2778-
"Invalid slice pitch provided");
2778+
"Invalid slice pitch provided");
27792779
}
27802780
} else if (image->mem_object_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) {
27812781
*image_slice_pitch = tmp_row_pitch;
27822782
} else {
27832783
*image_slice_pitch =
27842784
image->fields.image_objs.image_desc->image_height * tmp_row_pitch;
27852785
}
2786-
2786+
27872787
tmp_slice_pitch = *image_slice_pitch;
27882788
}
27892789

@@ -4169,6 +4169,7 @@ ACL_EXPORT CL_API_ENTRY cl_int CL_API_CALL clEnqueueMigrateMemObjectsIntelFPGA(
41694169
num_mem_objects * sizeof(acl_mem_migrate_wrapper_t));
41704170

41714171
if (!new_src_mem_list) {
4172+
free(needs_release_on_fail);
41724173
return CL_OUT_OF_RESOURCES;
41734174
}
41744175

@@ -4179,6 +4180,7 @@ ACL_EXPORT CL_API_ENTRY cl_int CL_API_CALL clEnqueueMigrateMemObjectsIntelFPGA(
41794180
num_mem_objects * sizeof(acl_mem_migrate_wrapper_t));
41804181

41814182
if (!local_event->cmd.info.memory_migration.src_mem_list) {
4183+
free(needs_release_on_fail);
41824184
return CL_OUT_OF_RESOURCES;
41834185
}
41844186
}
@@ -6825,9 +6827,9 @@ static void acl_dump_mem_internal(cl_mem mem) {
68256827
? "is malloc"
68266828
: "not malloc"));
68276829
printf(" .begin %p\n",
6828-
mem->block_allocation->range.begin);
6830+
mem->block_allocation->range.begin);
68296831
printf(" .end %p\n",
6830-
mem->block_allocation->range.next);
6832+
mem->block_allocation->range.next);
68316833
}
68326834
printf(" .mappings %d\n", mem->mapping_count);
68336835
acl_print_debug_msg(" .size %lu\n", mem->size);

0 commit comments

Comments
 (0)