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


[ROCm/clr commit: 821ae6a103]
Этот коммит содержится в:
Satyanvesh Dittakavi
2024-02-21 16:37:06 +00:00
родитель f120b0b805
Коммит 0595e7c41f
+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;