Skip to content

[L0] fix Coverity issues for L0 Adapter #1955

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 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event) {
EndTimeRecording.EventHasDied = true;
} else {
// Otherwise we evict the entry.
Legacy(Event->UrQueue)->EndTimeRecordings.erase(Entry);
Queue->EndTimeRecordings.erase(Entry);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/level_zero/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImportExternalMemoryExp(
break;
case UR_EXP_EXTERNAL_MEM_TYPE_OPAQUE_FD:
default:
delete importWin32;
delete externalMemoryData;
return UR_RESULT_ERROR_INVALID_VALUE;
}
importWin32->handle = Win32Handle->handle;
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ ur_result_t ur_queue_handle_legacy_t_::queueRelease() {
// internal reference count. When the External Reference count == 0, then
// cleanup of the queue begins and the final decrement of the internal
// reference count is completed.
Queue->RefCount.decrementAndTest();
static_cast<void>(Queue->RefCount.decrementAndTest());
return UR_RESULT_SUCCESS;
}

Expand Down
24 changes: 18 additions & 6 deletions source/adapters/level_zero/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc(
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
// L0 spec says that alignment values that are not powers of 2 are invalid.
if (Align > 65536 || (Align & (Align - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
// If alignment == 0, then we are allowing the L0 driver to choose the
// alignment so no need to check.
if (Align > 0) {
if (Align > 65536 || (Align & (Align - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
}

ur_platform_handle_t Plt = Context->getPlatform();
// If indirect access tracking is enabled then lock the mutex which is
Expand Down Expand Up @@ -381,8 +385,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc(
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
// L0 spec says that alignment values that are not powers of 2 are invalid.
if (Alignment > 65536 || (Alignment & (Alignment - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
// If alignment == 0, then we are allowing the L0 driver to choose the
// alignment so no need to check.
if (Alignment > 0) {
if (Alignment > 65536 || (Alignment & (Alignment - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
}

ur_platform_handle_t Plt = Device->Platform;

Expand Down Expand Up @@ -482,8 +490,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc(
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
// L0 spec says that alignment values that are not powers of 2 are invalid.
if (Alignment > 65536 || (Alignment & (Alignment - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
// If alignment == 0, then we are allowing the L0 driver to choose the
// alignment so no need to check.
if (Alignment > 0) {
if (Alignment > 65536 || (Alignment & (Alignment - 1)) != 0)
return UR_RESULT_ERROR_INVALID_VALUE;
}

ur_platform_handle_t Plt = Device->Platform;

Expand Down
Loading