2
0

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]
Este cometimento está contido em:
Satyanvesh Dittakavi
2024-02-21 16:37:06 +00:00
ascendente f120b0b805
cometimento 0595e7c41f
+6
Ver ficheiro
@@ -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;