From 05c3b0dc2e239678600a16c0567e194dba704f06 Mon Sep 17 00:00:00 2001 From: pbalcer Date: Wed, 24 Jan 2024 11:31:45 +0100 Subject: [PATCH] [L0] fix coverity issues --- source/adapters/level_zero/kernel.cpp | 5 +++++ source/adapters/level_zero/kernel.hpp | 2 +- source/adapters/level_zero/program.cpp | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/adapters/level_zero/kernel.cpp b/source/adapters/level_zero/kernel.cpp index bf131b73e2..7dc60a9bab 100644 --- a/source/adapters/level_zero/kernel.cpp +++ b/source/adapters/level_zero/kernel.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "kernel.hpp" +#include "ur_api.h" #include "ur_level_zero.hpp" UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( @@ -48,6 +49,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( ZeKernel = Kernel->ZeKernel; } else { auto It = Kernel->ZeKernelMap.find(ZeDevice); + if (It == Kernel->ZeKernelMap.end()) { + /* kernel and queue don't match */ + return UR_RESULT_ERROR_INVALID_QUEUE; + } ZeKernel = It->second; } // Lock automatically releases when this goes out of scope. diff --git a/source/adapters/level_zero/kernel.hpp b/source/adapters/level_zero/kernel.hpp index a6d85d2baa..b6ded8d604 100644 --- a/source/adapters/level_zero/kernel.hpp +++ b/source/adapters/level_zero/kernel.hpp @@ -15,7 +15,7 @@ struct ur_kernel_handle_t_ : _ur_object { ur_kernel_handle_t_(bool OwnZeHandle, ur_program_handle_t Program) - : Program{Program}, SubmissionsCount{0}, MemAllocs{} { + : Context{nullptr}, Program{Program}, SubmissionsCount{0}, MemAllocs{} { OwnNativeHandle = OwnZeHandle; } diff --git a/source/adapters/level_zero/program.cpp b/source/adapters/level_zero/program.cpp index 1cab028453..9f31d3fbc1 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -462,8 +462,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramLinkExp( new ur_program_handle_t_(State, hContext, ZeModuleMap.begin()->second, ZeBuildLogMap.begin()->second); *phProgram = reinterpret_cast(UrProgram); - (*phProgram)->ZeModuleMap = ZeModuleMap; - (*phProgram)->ZeBuildLogMap = ZeBuildLogMap; + (*phProgram)->ZeModuleMap = std::move(ZeModuleMap); + (*phProgram)->ZeBuildLogMap = std::move(ZeBuildLogMap); } catch (const std::bad_alloc &) { return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY; } catch (...) {