Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Fix false-positive coverity (#38293)

Bogdan Pereanu517af6a6bbcf
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.cpp
index e10397bc364..a1ed30426fc 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
@@ -273,10 +273,9 @@ void CompiledModelPropertyManager::registerProperties() {
[](const ov::AnyMap&) {
return true;
},
- [this](const ov::AnyMap&) {
- // 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();
+ [this](const ov::AnyMap&) -> ov::Any {
+ std::shared_ptr<const ov::Model> model = _config.get<MODEL_PTR>().lock();
+ return ov::Any(std::move(model));
},
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.cpp
index 95c598b79f6..6836de99126 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
@@ -905,9 +905,8 @@ void PluginPropertyManager::registerProperties() {
return _config.hasOpt(ov::hint::model.name());
},
[this](const ov::AnyMap&) -> ov::Any {
- // 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();
+ std::shared_ptr<const ov::Model> model = _config.get<MODEL_PTR>().lock();
+ return ov::Any(std::move(model));
},
[](const ov::Any&) {
OPENVINO_THROW("Property '", ov::hint::model.name(),"' can only be provided when importing a compiled model, it cannot be set otherwise");