diff --git a/unified-runtime/source/loader/layers/sanitizer/msan/msan_ddi.cpp b/unified-runtime/source/loader/layers/sanitizer/msan/msan_ddi.cpp index 6e3cca8490b2b..178aff3050481 100644 --- a/unified-runtime/source/loader/layers/sanitizer/msan/msan_ddi.cpp +++ b/unified-runtime/source/loader/layers/sanitizer/msan/msan_ddi.cpp @@ -367,9 +367,11 @@ ur_result_t urProgramLink( auto UrRes = pfnProgramLink(hContext, count, phPrograms, pOptions, phProgram); if (UrRes != UR_RESULT_SUCCESS) { - auto Devices = GetDevices(hContext); - PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size()); - UR_CALL(getMsanInterceptor()->insertProgram(*phProgram)); + if (*phProgram) { + auto Devices = GetDevices(hContext); + PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size()); + UR_CALL(getMsanInterceptor()->insertProgram(*phProgram)); + } return UrRes; } @@ -405,8 +407,10 @@ ur_result_t urProgramLinkExp( auto UrRes = pfnProgramLinkExp(hContext, numDevices, phDevices, flags, count, phPrograms, pOptions, phProgram); if (UrRes != UR_RESULT_SUCCESS) { - PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices); - UR_CALL(getMsanInterceptor()->insertProgram(*phProgram)); + if (*phProgram) { + PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices); + UR_CALL(getMsanInterceptor()->insertProgram(*phProgram)); + } return UrRes; } diff --git a/unified-runtime/source/loader/layers/sanitizer/tsan/tsan_ddi.cpp b/unified-runtime/source/loader/layers/sanitizer/tsan/tsan_ddi.cpp index e03e82a62bb62..a5c9d887d6cf5 100644 --- a/unified-runtime/source/loader/layers/sanitizer/tsan/tsan_ddi.cpp +++ b/unified-runtime/source/loader/layers/sanitizer/tsan/tsan_ddi.cpp @@ -197,9 +197,11 @@ ur_result_t urProgramLink( auto UrRes = getContext()->urDdiTable.Program.pfnLink( hContext, count, phPrograms, pOptions, phProgram); if (UrRes != UR_RESULT_SUCCESS) { - auto Devices = GetDevices(hContext); - PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size()); - UR_CALL(getTsanInterceptor()->insertProgram(*phProgram)); + if (*phProgram) { + auto Devices = GetDevices(hContext); + PrintUrBuildLogIfError(UrRes, *phProgram, Devices.data(), Devices.size()); + UR_CALL(getTsanInterceptor()->insertProgram(*phProgram)); + } return UrRes; } UR_CALL(getTsanInterceptor()->insertProgram(*phProgram)); @@ -364,8 +366,10 @@ ur_result_t urProgramLinkExp( hContext, numDevices, phDevices, flags, count, phPrograms, pOptions, phProgram); if (UrRes != UR_RESULT_SUCCESS) { - PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices); - UR_CALL(getTsanInterceptor()->insertProgram(*phProgram)); + if (*phProgram) { + PrintUrBuildLogIfError(UrRes, *phProgram, phDevices, numDevices); + UR_CALL(getTsanInterceptor()->insertProgram(*phProgram)); + } return UrRes; }