Skip to content

Commit 6f2a8e8

Browse files
Correct nullptr SVM arg handling
Related-To: NEO-5001 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 147dc0f commit 6f2a8e8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

opencl/source/kernel/svm_object_arg.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ GraphicsAllocation *SvmObjectArg::getGraphicsAllocation(uint32_t rootDeviceIndex
1818
DEBUG_BREAK_IF(singleDeviceSvmAlloc && rootDeviceIndex != singleDeviceSvmAlloc->getRootDeviceIndex());
1919
return singleDeviceSvmAlloc;
2020
}
21-
UNRECOVERABLE_IF(!multiDeviceSvmAlloc);
22-
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
21+
if (multiDeviceSvmAlloc) {
22+
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
23+
}
24+
return nullptr;
2325
}
2426

2527
bool SvmObjectArg::isCoherent() const {

opencl/test/unit_test/kernel/svm_object_arg_tests.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,18 @@ TEST(SvmObjectArgTest, givenMultiGraphicsAllocationWhenCreatingSvmObjectArgThenP
3939
EXPECT_EQ(multiGraphicsAllocation.getAllocationType(), svmObjectArg.getAllocationType());
4040
EXPECT_EQ(&multiGraphicsAllocation, svmObjectArg.getMultiDeviceSvmAlloc());
4141
}
42+
43+
TEST(SvmObjectArgTest, givenNullPtrAllocationWhenGettingGraphicsAllocationFromSvmObjectArgThenNullptrIsReturned) {
44+
{
45+
GraphicsAllocation *nullGraphicsAllocation = nullptr;
46+
SvmObjectArg svmObjectArg(nullGraphicsAllocation);
47+
48+
EXPECT_EQ(nullptr, svmObjectArg.getGraphicsAllocation(0u));
49+
}
50+
{
51+
MultiGraphicsAllocation *nullMultiGraphicsAllocation = nullptr;
52+
SvmObjectArg svmObjectArg(nullMultiGraphicsAllocation);
53+
54+
EXPECT_EQ(nullptr, svmObjectArg.getGraphicsAllocation(0u));
55+
}
56+
}

0 commit comments

Comments
 (0)