diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index 76821cfe38..41b9038d0c 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -340,10 +340,6 @@ hipError_t ihipLaunchKernelCommand(amd::Command*& command, hipFunction_t f, return hipErrorOutOfMemory; } - if (kernelCommand->status() == CL_INVALID_OPERATION) { - kernelCommand->release(); - return hipErrorIllegalState; - } command = kernelCommand; return hipSuccess; @@ -398,6 +394,12 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, hip::Event* eStop = reinterpret_cast(stopEvent); eStop->BindCommand(*command, false); } + + if (command->status() == CL_INVALID_OPERATION) { + command->release(); + return hipErrorIllegalState; + } + command->release(); return hipSuccess;