OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU] Coverity issue fix (#36678)
Chenhu Wang24d7ad0e80c7
diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_gathermatmul_executor.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_gathermatmul_executor.cppindex 46496ac05ca..e4395c92c8a 100644--- a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_gathermatmul_executor.cpp+++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_gathermatmul_executor.cpp@@ -370,7 +370,7 @@ GatherMatmulDnnlExecutor::GatherMatmulDnnlExecutor([[maybe_unused]] const Gathercontext->getPrivateWeightCache(),threadPool);- if (!scale_shape.empty()) {+ if (scalesMem && !scale_shape.empty()) {auto expectedScaleMemDesc =MemoryDescUtils::convertToDnnlMemoryDesc(DnnlExtensionUtils::makeDescriptor(m_gemvImpl->get_scale_md()));const auto& scDims = scalesMem->getShape().getStaticDims();@@ -384,7 +384,7 @@ GatherMatmulDnnlExecutor::GatherMatmulDnnlExecutor([[maybe_unused]] const Gather}}- if (!zp_shape.empty()) {+ if (zpMem && !zp_shape.empty()) {auto expectedZpMemDesc =MemoryDescUtils::convertToDnnlMemoryDesc(DnnlExtensionUtils::makeDescriptor(m_gemvImpl->get_zp_md()));const auto& zpDims = zpMem->getShape().getStaticDims();diff --git a/src/plugins/intel_cpu/src/nodes/pa_kv_reorder.cpp b/src/plugins/intel_cpu/src/nodes/pa_kv_reorder.cppindex 4f0cd5e5b2a..3d6e7fd55b6 100644--- a/src/plugins/intel_cpu/src/nodes/pa_kv_reorder.cpp+++ b/src/plugins/intel_cpu/src/nodes/pa_kv_reorder.cpp@@ -136,8 +136,12 @@ void PaKVReorder::execute([[maybe_unused]] const dnnl::stream& strm) {}auto* out = getDstDataAtPort(0);- if (out != nullptr && !getDstMemoryAtPort(0)->getShape().hasZeroDims()) {- std::memset(out, 0, getDstMemoryAtPort(0)->getDesc().getCurrentMemSize());+ const auto& outputMemory = getDstMemoryAtPort(0);+ const auto& outputShape = outputMemory->getShape();+ if (out != nullptr && outputShape.isStatic() && !outputShape.hasZeroDims()) {+ const auto outputSize = outputMemory->getDesc().getCurrentMemSize();+ CPU_NODE_ASSERT(outputSize != MemoryDesc::UNDEFINED_SIZE, "KV output tensor size is undefined");+ std::memset(out, 0, outputSize);}}