Skip to content

Commit 7070261

Browse files
committed
[UR][*SAN] Check device ptr before AllocExportableMemoryExp call
1 parent d0f8f84 commit 7070261

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

unified-runtime/source/loader/layers/sanitizer/asan/asan_interceptor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ ur_result_t AsanInterceptor::allocateMemory(ur_context_handle_t Context,
9797
Params.Pool ? Params.Pool : ContextInfo->getUSMPool(),
9898
Type, &Allocated));
9999
} else {
100+
// Check if the device is not NULL as AllocExportableMemoryExp requires it
101+
if (!Device) {
102+
return UR_RESULT_ERROR_INVALID_ARGUMENT;
103+
}
104+
100105
UR_CALL(
101106
getContext()->urDdiTable.MemoryExportExp.pfnAllocExportableMemoryExp(
102107
Context, Device, Alignment, NeededSize, Params.HandleTypeToExport,

unified-runtime/source/loader/layers/sanitizer/msan/msan_interceptor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ ur_result_t MsanInterceptor::allocateMemory(ur_context_handle_t Context,
7575
UR_CALL(SafeAllocate(Context, Device, Size, &NewProperties, Params.Pool,
7676
Type, &Allocated));
7777
} else {
78+
// Check if the device is not NULL as AllocExportableMemoryExp requires it
79+
if (!Device) {
80+
return UR_RESULT_ERROR_INVALID_ARGUMENT;
81+
}
82+
7883
UR_CALL(
7984
getContext()->urDdiTable.MemoryExportExp.pfnAllocExportableMemoryExp(
8085
Context, Device, Alignment, Size, Params.HandleTypeToExport,

0 commit comments

Comments
 (0)