Skip to content

Klocwork check null before dereference in acl_kernel_if #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 14, 2021
8 changes: 8 additions & 0 deletions src/acl_kernel_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,13 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
// Allocations for each kernel
kern->accel_csr = (acl_kernel_if_addr_range *)acl_malloc(
kern->num_accel * sizeof(acl_kernel_if_addr_range));
assert(kern->accel_csr);
kern->accel_perf_mon = (acl_kernel_if_addr_range *)acl_malloc(
kern->num_accel * sizeof(acl_kernel_if_addr_range));
assert(kern->accel_perf_mon);
kern->accel_num_printfs =
(unsigned int *)acl_malloc(kern->num_accel * sizeof(unsigned int));
assert(kern->accel_num_printfs);

// The Kernel CSR registers
// The new and improved config ROM give us the address *offsets* from
Expand Down Expand Up @@ -946,13 +949,18 @@ int acl_kernel_if_update(const acl_device_def_autodiscovery_t &devdef,
if (kern->num_accel > 0) {
kern->accel_job_ids =
(int volatile **)acl_malloc(kern->num_accel * sizeof(int *));
assert(kern->accel_job_ids);

kern->accel_invoc_queue_depth =
(unsigned int *)acl_malloc(kern->num_accel * sizeof(unsigned int));
assert(kern->accel_invoc_queue_depth);

// Kernel IRQ is a separate thread. Need to use circular buffer to make this
// multithread safe.
kern->accel_queue_front = (int *)acl_malloc(kern->num_accel * sizeof(int));
assert(kern->accel_queue_front);
kern->accel_queue_back = (int *)acl_malloc(kern->num_accel * sizeof(int));
assert(kern->accel_queue_back);

for (unsigned a = 0; a < kern->num_accel; ++a) {
unsigned int max_same_accel_launches =
Expand Down