Skip to content

check for null dereference in trackingOpenIpcHandle #419

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 8 additions & 2 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,23 @@ static umf_result_t trackingOpenIpcHandle(void *provider, void *providerIpcData,
(umf_tracking_memory_provider_t *)provider;
umf_result_t ret = UMF_RESULT_SUCCESS;

if (p->hUpstream == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it is possible? If it happens it indicates error in UMF code, right? If so, I think it should be just assert.

I agree that && p->hUpstream checks below should be just removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a fix for coverity. Agree that this should never happen but I think it is better to add this code that add a false-positive

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO if it is really a false-positive it is much better to ignore it in Coverity than add a redundant code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bratpiorka I propose sth like that #420 instead and ignore this issue in Coverity.

LOG_ERR("tracking open ipc handle failed: no upstream provider");
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
}

ret = umfMemoryProviderOpenIPCHandle(p->hUpstream, providerIpcData, ptr);
if (ret != UMF_RESULT_SUCCESS) {
return ret;
}
size_t bufferSize = getDataSizeFromIpcHandle(providerIpcData);
ret = umfMemoryTrackerAdd(p->hTracker, p->pool, *ptr, bufferSize);
if (ret != UMF_RESULT_SUCCESS && p->hUpstream) {
if (ret != UMF_RESULT_SUCCESS) {
if (umfMemoryProviderCloseIPCHandle(p->hUpstream, *ptr)) {
// TODO: LOG
LOG_ERR("failed to close IPC handle");
}
}

return ret;
}

Expand Down