rocr: Return err when freeing invalid pointer

Return false if trying to free a NULL pointer (or invalid size)
internally in ROCr. This is to detect errors within ROCr when trying
to free NULL pointers. If a user of ROCr tries to free a NULL
pointer, this condition should be caught at the beginning of the
Runtime::FreeMemory(...) function and return HSA_STATUS_SUCCESS. This
matches the behavior of the free(...) or delete functions that
silently ignores calls when the passed a NULL pointer.

Change-Id: I84bc26928b35023e19cd9f214b42c6ee9508029c
Этот коммит содержится в:
David Yat Sin committed 2024-09-19 19:44:53 +00:00
1 родитель 561c44a4a9
Коммит 0af7a54ebe
1 file changed
+1 -1
+1 -1
Просмотреть файл
@@ -259,7 +259,7 @@ void *KfdDriver::AllocateKfdMemory(const HsaMemFlags &flags, uint32_t node_id,
bool KfdDriver::FreeKfdMemory(void *mem, size_t size) {
if (mem == nullptr || size == 0) {
debug_print("Invalid free ptr:%p size:%lu\n", mem, size);
return true;
return false;
}
if (hsaKmtFreeMemory(mem, size) != HSAKMT_STATUS_SUCCESS) {