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]
Ta zmiana jest zawarta w:
%! (template.HTML=Satyanvesh Dittakavi)złożyło 2024-02-21 16:37:21 +00:00
1 rodzic f120b0b805
złożenie 0595e7c41f
Plik 1 zmieniony
+6
+6
Wyświetl plik
@@ -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;