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
[NPU] Fix Coverity issues (#38068)
Bogdan Pereanu852b8e116a87
diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cppindex 7db7112efc1..e10397bc364 100644--- a/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model_property_manager.cpp@@ -93,6 +93,8 @@ void CompiledModelPropertyManager::setProperty(const ov::AnyMap& properties) {for (const auto& property : properties) {const auto propertyIt = _properties.find(property.first);+ // This should never happen due to the previous check, fixing potential issue with missing property+ OPENVINO_ASSERT(propertyIt != _properties.end(), "Unsupported configuration key: ", property.first);propertyIt->second.set(property.second);}}@@ -272,7 +274,9 @@ void CompiledModelPropertyManager::registerProperties() {return true;},[this](const ov::AnyMap&) {- return _config.get<MODEL_PTR>().lock();+ // Retrieve the weak pointer to the model and lock it to get a shared pointer. Fix potential dangling pointer issue.+ const auto model = _config.get<MODEL_PTR>();+ return model.lock();},readOnlySetter);diff --git a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cppindex 1ea5bedeec4..fff3b8bbd58 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin_property_manager.cpp@@ -826,7 +826,9 @@ void PluginPropertyManager::registerProperties() {return _config.hasOpt(ov::hint::model.name());},[this](const ov::AnyMap&) -> ov::Any {- return _config.get<MODEL_PTR>().lock();+ // Retrieve the weak pointer to the model and lock it to get a shared pointer. Fix potential dangling pointer issue.+ const auto model = _config.get<MODEL_PTR>();+ return model.lock();},[](const ov::Any&) {OPENVINO_THROW("Property '", ov::hint::model.name(),"' can only be provided when importing a compiled model, it cannot be set otherwise");