From ba3da9b3ec0e4d6cd0afff5aec9bacab5a90ebb6 Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 20 Dec 2019 13:02:52 -0600
Subject: [PATCH] P4 to Git Change 2049240 by lmoriche@lmoriche_opencl_dev2 on
2019/12/20 13:54:17
SWDEV-216705 - [hipclang-vdi-rocm][FBA-80]Test crash when all GPUs are hidden by ROCR_VISIBLE_DEVICES
Return an error instead of dereferencing a null pointer. This should address the issue described
in the ticket, but more places need fixing in the runtime to avoid crashes for corner cases.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#59 edit
---
hipamd/api/hip/hip_platform.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hipamd/api/hip/hip_platform.cpp b/hipamd/api/hip/hip_platform.cpp
index 1aa356cd36..c91199c077 100644
--- a/hipamd/api/hip/hip_platform.cpp
+++ b/hipamd/api/hip/hip_platform.cpp
@@ -569,6 +569,9 @@ extern "C" hipError_t hipLaunchKernel(const void *hostFunction,
stream);
int deviceId = ihipGetDevice();
+ if (deviceId == -1) {
+ HIP_RETURN(hipErrorNoDevice);
+ }
hipFunction_t func = PlatformState::instance().getFunc(hostFunction, deviceId);
if (func == nullptr) {
HIP_RETURN(hipErrorInvalidDeviceFunction);