Skip to content

Commit 7f488b8

Browse files
addressed segfault and return errors
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 9aeb474 commit 7f488b8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

unified-runtime/source/adapters/level_zero/context.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
464464
ze_result_t Result = ZE_CALL_NOCHECK(
465465
zeEventPoolCreate,
466466
(ZeContext, &ZeEventPoolDesc, ZeDevices.size(), &ZeDevices[0], &Pool));
467-
if (ze2urResult(Result) == UR_RESULT_ERROR_OUT_OF_RESOURCES &&
467+
if (ze2urResult(Result) == UR_RESULT_ERROR_OUT_OF_RESOURCES && Queue &&
468468
!Queue->isInOrderQueue()) {
469469
if (Queue->UsingImmCmdLists) {
470470
UR_CALL(CleanupEventsInImmCmdLists(Queue, true /*QueueLocked*/,
@@ -475,6 +475,8 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
475475
}
476476
ZE2UR_CALL(zeEventPoolCreate, (ZeContext, &ZeEventPoolDesc,
477477
ZeDevices.size(), &ZeDevices[0], &Pool));
478+
} else if (ze2urResult(Result) != UR_RESULT_SUCCESS) {
479+
return ze2urResult(Result);
478480
}
479481
Index = 0;
480482
NumEventsAvailableInEventPool[Pool] = MaxNumEventsPerPool - 1;
@@ -562,7 +564,7 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
562564
ze_result_t Result = ZE_CALL_NOCHECK(
563565
zeEventPoolCreate,
564566
(ZeContext, &ZeEventPoolDesc, ZeDevices.size(), &ZeDevices[0], &Pool));
565-
if (ze2urResult(Result) == UR_RESULT_ERROR_OUT_OF_RESOURCES &&
567+
if (ze2urResult(Result) == UR_RESULT_ERROR_OUT_OF_RESOURCES && Queue &&
566568
!Queue->isInOrderQueue()) {
567569
if (Queue->UsingImmCmdLists) {
568570
UR_CALL(CleanupEventsInImmCmdLists(Queue, true /*QueueLocked*/,
@@ -573,6 +575,8 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
573575
}
574576
ZE2UR_CALL(zeEventPoolCreate, (ZeContext, &ZeEventPoolDesc,
575577
ZeDevices.size(), &ZeDevices[0], &Pool));
578+
} else if (ze2urResult(Result) != UR_RESULT_SUCCESS) {
579+
return ze2urResult(Result);
576580
}
577581
NumEventsAvailableInEventPool[*ZePool] = MaxNumEventsPerPool - 1;
578582
NumEventsUnreleasedInEventPool[*ZePool] = 1;

0 commit comments

Comments
 (0)