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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user