SWDEV-537855 - Free created event if hipIpcOpenEventHandle fails (#680)

このコミットが含まれているのは:
Stojiljkovic, Vladana
2025-08-13 11:36:13 +02:00
committed by GitHub
コミット 499e2ee044
+12 -5
ファイルの表示
@@ -201,16 +201,23 @@ hipError_t hipIpcGetEventHandle(hipIpcEventHandle_t* handle, hipEvent_t event) {
hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle) { hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle) {
HIP_INIT_API(hipIpcOpenEventHandle, event, handle); HIP_INIT_API(hipIpcOpenEventHandle, event, handle);
hipError_t hip_err = hipSuccess; hipError_t status = hipSuccess;
if (event == nullptr) { if (event == nullptr) {
HIP_RETURN(hipErrorInvalidValue); HIP_RETURN(hipErrorInvalidValue);
} }
hip_err = ihipEventCreateWithFlags(event, hipEventDisableTiming | hipEventInterprocess);
if (hip_err != hipSuccess) { status = ihipEventCreateWithFlags(event, hipEventDisableTiming | hipEventInterprocess);
HIP_RETURN(hip_err); if (status != hipSuccess) {
HIP_RETURN(status);
} }
hip::Event* e = reinterpret_cast<hip::Event*>(*event); hip::Event* e = reinterpret_cast<hip::Event*>(*event);
ihipIpcEventHandle_t* iHandle = reinterpret_cast<ihipIpcEventHandle_t*>(&handle); ihipIpcEventHandle_t* iHandle = reinterpret_cast<ihipIpcEventHandle_t*>(&handle);
HIP_RETURN(e->OpenHandle(iHandle)); status = e->OpenHandle(iHandle);
// Free the event in case of failure
if (status != hipSuccess) {
delete e;
}
HIP_RETURN(status);
} }
} // namespace hip } // namespace hip