From 503fd728dd91156d1f2f9ebd074f33d417df16b2 Mon Sep 17 00:00:00 2001 From: "Zhuravlyov, Konstantin (x21446) MA" Date: Sat, 9 Apr 2016 16:40:24 -0500 Subject: [PATCH] Fail gracefully if memory allocation did not succeed Testing: precheckin (http://ocltc.amd.com:8111/viewModification.html?modId=69427&personal=true&tab=vcsModificationBuilds) [git-p4: depot-paths = "//depot/stg/hsa/drivers/hsa/runtime/": change = 1256179] --- runtime/hsa-runtime/core/runtime/amd_loader_context.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_loader_context.cpp b/runtime/hsa-runtime/core/runtime/amd_loader_context.cpp index b38a25ad4b..3927d67824 100644 --- a/runtime/hsa-runtime/core/runtime/amd_loader_context.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_loader_context.cpp @@ -472,7 +472,10 @@ void* LoaderContext::SegmentAlloc(amdgpu_hsa_elf_segment_t segment, if (nullptr == mem) { return nullptr; } - mem->Allocate(size, align, zero); + if (!mem->Allocate(size, align, zero)) { + delete mem; + return nullptr; + } return mem; }