From c0f779fdf11529d8f9d5dfbe2f3c64a06a486558 Mon Sep 17 00:00:00 2001 From: pghafari Date: Fri, 2 Dec 2022 09:15:22 -0500 Subject: [PATCH] SWDEV-369576, SWDEV-369578, SWDEV-369577, SWDEV-369579, SWDEV-369563 - matching cuda return value SWDEV-369576, SWDEV-369578, SWDEV-369579, SWDEV-369563 - matching cuda return value Change-Id: I21b598e959571979307238c485492eb7fe2388cc --- hipamd/src/hip_module.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index 1602409c2c..070dbe9881 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -41,7 +41,9 @@ static uint64_t ElfSize(const void* emi) { return amd::Elf::getElfSize(emi); } hipError_t hipModuleUnload(hipModule_t hmod) { HIP_INIT_API(hipModuleUnload, hmod); - + if (hmod == nullptr) { + HIP_RETURN(hipErrorInvalidResourceHandle); + } HIP_RETURN(PlatformState::instance().unloadModule(hmod)); } @@ -91,10 +93,13 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes, hipModule_t h if (dptr == nullptr || bytes == nullptr) { // If either is nullptr, ignore it - return hipSuccess; + HIP_RETURN(hipSuccess); } - if (name == nullptr) { - return hipErrorInvalidValue; + if ((dptr == nullptr && bytes == nullptr) || name == nullptr || strlen(name) == 0) { + HIP_RETURN(hipErrorInvalidValue); + } + if (hmod == nullptr) { + HIP_RETURN(hipErrorInvalidResourceHandle); } /* Get address and size for the global symbol */ if (hipSuccess != PlatformState::instance().getDynGlobalVar(name, hmod, dptr, bytes)) { @@ -669,6 +674,10 @@ hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const if ((texRef == nullptr) || (name == nullptr)) { HIP_RETURN(hipErrorInvalidValue); } + if (hmod == nullptr) { + HIP_RETURN(hipErrorInvalidResourceHandle); + } + amd::Device* device = hip::getCurrentDevice()->devices()[0]; const device::Info& info = device->info(); if (!info.imageSupport_) {