From 420ec4eeaec91906ae33bd65ca02a0ce059091e1 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 10 Aug 2020 18:25:31 +0000 Subject: [PATCH] Return error from hipMallocManaged for size =0 Change-Id: Ida0cecf05e1df731176d41e59422d1e606cc9bd9 [ROCm/clr commit: 236ef9416627f14565f8c826f9b2b1668ed67f19] --- projects/clr/hipamd/rocclr/hip_hmm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/rocclr/hip_hmm.cpp b/projects/clr/hipamd/rocclr/hip_hmm.cpp index ab787e195e..b9df3b25d6 100644 --- a/projects/clr/hipamd/rocclr/hip_hmm.cpp +++ b/projects/clr/hipamd/rocclr/hip_hmm.cpp @@ -59,7 +59,7 @@ static_assert(static_cast(hipMemRangeAttributeLastPrefetchLocation) == hipError_t hipMallocManaged(void** dev_ptr, size_t size, unsigned int flags) { HIP_INIT_API(hipMallocManaged, dev_ptr, size, flags); - if ((dev_ptr == nullptr) || (flags != hipMemAttachGlobal)) { + if ((dev_ptr == nullptr) || (size == 0) || (flags != hipMemAttachGlobal)) { HIP_RETURN(hipErrorInvalidValue); } @@ -213,4 +213,4 @@ static hipError_t ihipMallocManaged(void** ptr, size_t size) { ClPrint(amd::LOG_INFO, amd::LOG_API, "%-5d: [%zx] ihipMallocManaged ptr=0x%zx", getpid(), std::this_thread::get_id(), *ptr); return hipSuccess; -} \ No newline at end of file +}