Skip to content
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

Fixed coverity in acl_hostch.cpp #233

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/acl_hostch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ CL_API_ENTRY cl_int CL_API_CALL clReadPipeIntelFPGA(cl_mem pipe, void *ptr) {
acl_idle_update(pipe->context);
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

// Error checking
if (pipe->host_pipe_info == NULL) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
"This pipe is not a host pipe");
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

// Error checking
if (!(pipe->flags & CL_MEM_HOST_READ_ONLY)) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
Expand Down Expand Up @@ -349,14 +349,14 @@ CL_API_ENTRY cl_int CL_API_CALL clWritePipeIntelFPGA(cl_mem pipe, void *ptr) {
acl_idle_update(pipe->context);
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

// Error checking
if (pipe->host_pipe_info == NULL) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
"This pipe is not a host pipe");
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

if (!(pipe->flags & CL_MEM_HOST_WRITE_ONLY)) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
Expand Down Expand Up @@ -465,6 +465,11 @@ CL_API_ENTRY void *CL_API_CALL clMapHostPipeIntelFPGA(cl_mem pipe,
acl_idle_update(pipe->context);
}

if (pipe->host_pipe_info == NULL) {
BAIL_INFO(CL_INVALID_MEM_OBJECT, pipe->context,
"This pipe is not a host pipe");
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

if (errcode_ret) {
Expand All @@ -479,12 +484,6 @@ CL_API_ENTRY void *CL_API_CALL clMapHostPipeIntelFPGA(cl_mem pipe,
}
*mapped_size = 0;

if (pipe->host_pipe_info == NULL) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
BAIL_INFO(CL_INVALID_MEM_OBJECT, pipe->context,
"This pipe is not a host pipe");
}

if (!pipe->host_pipe_info->m_binded_kernel) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
BAIL_INFO(CL_INVALID_KERNEL, pipe->context,
Expand Down Expand Up @@ -595,14 +594,14 @@ clUnmapHostPipeIntelFPGA(cl_mem pipe, void *mapped_ptr, size_t size_to_unmap,
acl_idle_update(pipe->context);
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

// Error checking
if (pipe->host_pipe_info == NULL) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_MEM_OBJECT, pipe->context,
"This pipe is not a host pipe");
}

acl_mutex_lock(&(pipe->host_pipe_info->m_lock));

// Error checking
if (!pipe->host_pipe_info->m_binded_kernel) {
acl_mutex_unlock(&(pipe->host_pipe_info->m_lock));
ERR_RET(CL_INVALID_KERNEL, pipe->context,
Expand Down