SWDEV-426272 - hipPointerGetAttribute shouldn't segfault when host ptr is passed

Check the pointer if its present in the arrayset before trying to dereference
it as it can cause access violation if the pointer is allocated using malloc

Change-Id: Ida72b9015dc22269fc1fbe0728e66e3de29fda3d
이 커밋은 다음에 포함됨:
Satyanvesh Dittakavi
2024-02-21 16:37:06 +00:00
부모 4c28f4aefd
커밋 821ae6a103
+6
파일 보기
@@ -3725,6 +3725,12 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
((CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_USE_HOST_PTR) &
memObj->getMemFlags())? hipMemoryTypeHost : hipMemoryTypeDevice;
} else { // checks for array type
// ptr must be a host allocation using malloc since memObj is null and is
// not found in hipArraySet.
if (hip::hipArraySet.find(static_cast<hipArray*>(ptr)) == hip::hipArraySet.end()) {
*reinterpret_cast<uint32_t*>(data) = 0;
return hipErrorInvalidValue;
}
cl_mem dstMemObj = reinterpret_cast<cl_mem>((static_cast<hipArray*>(ptr))->data);
if (!is_valid(dstMemObj)) {
*reinterpret_cast<uint32_t*>(data) = 0;