Skip to content

Commit 8080e26

Browse files
praaszt-jankowskimlukasze
authored
[coverity, core] Fix high IE common issues 25.4 (#32441)
### Details: - CID2425741 Dereference of potentially null field - CID2425714 Dereference of potentially null field - CID2425706 Dereference of potentially null field ### Tickets: - CVS-175071 --------- Signed-off-by: Pawel Raasz <[email protected]> Signed-off-by: Raasz, Pawel <[email protected]> Co-authored-by: Tomasz Jankowski <[email protected]> Co-authored-by: Michal Lukaszewski <[email protected]>
1 parent 79741b3 commit 8080e26

File tree

9 files changed

+38
-25
lines changed

9 files changed

+38
-25
lines changed

.github/workflows/windows_vs2022_debug.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
repo_token: ${{ secrets.GITHUB_TOKEN }}
4949
skip_when_only_listed_labels_set: 'docs'
5050
skip_when_only_listed_files_changed: '*.md,*.rst,*.png,*.jpg,*.svg,*/layer_tests_summary/*,*/conformance/*'
51-
51+
5252
- name: Get target branch
5353
id: set_target_branch
5454
run: |
@@ -81,8 +81,8 @@ jobs:
8181
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
8282
os: 'windows_2022'
8383
build-type: 'Debug'
84-
timeout-minutes: 60
85-
84+
timeout-minutes: 90
85+
8686
Overall_Status:
8787
name: ci/gha_overall_status_windows_debug
8888
needs: [ Smart_CI, Build, CXX_Unit_Tests ]

src/core/src/runtime/allocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool Allocator::operator==(const Allocator& other) const {
8686
if (_impl == other._impl) {
8787
return true;
8888
}
89-
return _impl->is_equal(*other._impl);
89+
return other._impl && _impl->is_equal(*other._impl);
9090
});
9191
}
9292

src/core/tests/ov_default_allocator_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "openvino/core/except.hpp"
1111
#include "openvino/runtime/allocator.hpp"
1212

13+
namespace ov::test {
14+
using ::testing::_;
1315
using OVDefaultAllocatorTest = ::testing::Test;
1416

1517
TEST_F(OVDefaultAllocatorTest, notThrowOnZeroSize) {
@@ -59,3 +61,12 @@ TEST_F(OVDefaultAllocatorTest, canAllocate10KMemory) {
5961
EXPECT_EQ(ptr[9999], 11);
6062
allocator.deallocate(handle);
6163
}
64+
65+
TEST_F(OVDefaultAllocatorTest, compareIfImplIsNull) {
66+
auto a1 = ov::Allocator();
67+
auto a2 = std::move(a1);
68+
69+
EXPECT_FALSE(a2 == a1);
70+
OV_EXPECT_THROW(std::ignore = (a1 == a2), ov::Exception, _);
71+
}
72+
} // namespace ov::test

src/inference/src/dev/core_impl.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,16 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const {
783783
// here we can store values like GPU.0, GPU.1 and we need to set properties to plugin
784784
// for each such .0, .1, .# device to make sure plugin can handle different settings for different
785785
// device IDs
786-
for (auto pluginDesc : pluginRegistry) {
787-
ov::DeviceIDParser parser(pluginDesc.first);
788-
if (pluginDesc.first.find(deviceName) != std::string::npos && !parser.get_device_id().empty()) {
789-
pluginDesc.second.defaultConfig[deviceKey] = parser.get_device_id();
790-
plugin.set_property(pluginDesc.second.defaultConfig);
786+
{
787+
std::unique_lock<std::mutex> g_lock(get_mutex());
788+
for (auto pluginDesc : pluginRegistry) {
789+
ov::DeviceIDParser parser(pluginDesc.first);
790+
if (pluginDesc.first.find(deviceName) != std::string::npos &&
791+
!parser.get_device_id().empty()) {
792+
g_lock.unlock();
793+
pluginDesc.second.defaultConfig[deviceKey] = parser.get_device_id();
794+
plugin.set_property(pluginDesc.second.defaultConfig);
795+
}
791796
}
792797
}
793798
}

src/inference/src/dev/plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const ov::Version ov::Plugin::get_version() const {
4545
}
4646

4747
void ov::Plugin::set_property(const ov::AnyMap& config) {
48-
m_ptr->set_property(config);
48+
OV_PLUGIN_CALL_STATEMENT(m_ptr->set_property(config));
4949
}
5050

5151
ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<const ov::Model>& model,
@@ -108,7 +108,7 @@ ov::SoPtr<ov::IRemoteContext> ov::Plugin::get_default_context(const AnyMap& para
108108
}
109109

110110
ov::Any ov::Plugin::get_property(const std::string& name, const AnyMap& arguments) const {
111-
return {m_ptr->get_property(name, arguments), {m_so}};
111+
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->get_property(name, arguments), {m_so}});
112112
}
113113

114114
bool ov::Plugin::supports_model_caching(const ov::AnyMap& arguments) const {

src/inference/tests/functional/caching_test.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,7 @@ class CachingTest : public ::testing::TestWithParam<std::tuple<TestParam, std::s
444444
return res;
445445
}));
446446

447-
EXPECT_CALL(plugin, set_property(_)).Times(AnyNumber()).WillRepeatedly(Invoke([](const ov::AnyMap&) {
448-
OPENVINO_NOT_IMPLEMENTED;
449-
}));
447+
EXPECT_CALL(plugin, set_property(_)).Times(AnyNumber());
450448
}
451449
};
452450

src/inference/tests/functional/ov_core_threading.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ TEST_F(CoreThreadingTests, SetConfigPluginDoesNotExist) {
9090
TEST_F(CoreThreadingTests, RegisterPlugin) {
9191
ov::Core core;
9292
std::atomic<int> index{0};
93-
auto plugin_path = ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
94-
std::string("mock_engine") + OV_BUILD_POSTFIX);
93+
const auto plugin_path = ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
94+
std::string("mock_engine") + OV_BUILD_POSTFIX);
9595
runParallel(
9696
[&]() {
97-
const std::string deviceName = std::to_string(index++);
97+
const auto deviceName = std::to_string(index++);
9898
core.register_plugin(plugin_path, deviceName);
9999
core.get_versions(deviceName);
100100
core.unload_plugin(deviceName);
@@ -110,12 +110,12 @@ TEST_F(CoreThreadingTests, RegisterPlugins) {
110110
# endif
111111
ov::Core core;
112112
std::atomic<unsigned int> index{0};
113-
auto file_prefix = ov::test::utils::generateTestFilePrefix();
114-
auto plugin_path = ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
115-
std::string("mock_engine") + OV_BUILD_POSTFIX);
113+
const auto file_prefix = ov::test::utils::generateTestFilePrefix();
114+
const auto plugin_path = ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
115+
std::string("mock_engine") + OV_BUILD_POSTFIX);
116116

117117
auto getPluginXml = [&]() -> std::tuple<std::filesystem::path, std::string> {
118-
std::string indexStr = std::to_string(index++);
118+
const auto indexStr = std::to_string(index++);
119119
std::filesystem::path pluginsXML = file_prefix + indexStr + ".xml";
120120
std::ofstream file(pluginsXML);
121121

@@ -127,7 +127,7 @@ TEST_F(CoreThreadingTests, RegisterPlugins) {
127127
file.flush();
128128
file.close();
129129

130-
return std::tie(pluginsXML, indexStr);
130+
return std::make_tuple(pluginsXML, indexStr);
131131
};
132132

133133
runParallel(

src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ class MockPlugin : public ov::IPlugin {
212212
if (it.first == ov::num_streams.name())
213213
num_streams = it.second.as<ov::streams::Num>();
214214
}
215-
OPENVINO_NOT_IMPLEMENTED;
216215
}
217216

218217
ov::Any get_property(const std::string& name, const ov::AnyMap& arguments) const override {

src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class MockInternalPlugin : public ov::IPlugin {
2121
ov::IPlugin* m_plugin = nullptr;
22-
ov::AnyMap config;
22+
ov::AnyMap config{};
2323

2424
public:
2525
explicit MockInternalPlugin(ov::IPlugin* target) : m_plugin(target) {}
@@ -57,7 +57,7 @@ class MockInternalPlugin : public ov::IPlugin {
5757
ov::Any get_property(const std::string& name, const ov::AnyMap& arguments) const override {
5858
if (m_plugin)
5959
return m_plugin->get_property(name, arguments);
60-
OPENVINO_NOT_IMPLEMENTED;
60+
return "";
6161
}
6262

6363
ov::SoPtr<ov::IRemoteContext> create_context(const ov::AnyMap& remote_properties) const override {

0 commit comments

Comments
 (0)