Skip to content

Runtime Coverity fixes #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 21, 2024
Merged

Runtime Coverity fixes #376

merged 6 commits into from
Aug 21, 2024

Conversation

sophimao
Copy link
Contributor

New issues scanned with Coverity 2024.3.0

@sophimao sophimao force-pushed the coverity-fixes branch 5 times, most recently from 436448e to 925889f Compare August 20, 2024 21:25
Fixes:
```
lib/pkg_editor/test/pkg_editor_test.cpp:468:29:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:405:32:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:430:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:437:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:438:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:439:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:493:5:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:498:30:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:886:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:896:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:900:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:901:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_auto_configure.cpp:903:7:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_hal_mmd.cpp:2945:40:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_program.cpp:1375:5:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)

src/acl_usm.cpp:170:9:
  Type: Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)
```
Fixes:
```
test/acl_auto_configure_test.cpp:285:3:
  Type: Using invalid iterator (INVALIDATE_ITERATOR)
test/acl_auto_configure_test.cpp:285:3:
  124. deref_iterator: Dereferencing iterator "kernel15_dev_global" though it is already past the end of its container.

test/acl_auto_configure_test.cpp:292:3:
  Type: Using invalid iterator (INVALIDATE_ITERATOR)
test/acl_auto_configure_test.cpp:292:3:
  136. deref_iterator: Dereferencing iterator "kernel15_dev_global2" though it is already past the end of its container.
```
Fixes:
```
lib/pkg_editor/src/pkg_editor.c:1486:5:
  Type: Resource leak (RESOURCE_LEAK)

lib/pkg_editor/src/pkg_editor.c:1468:3:
  1. path: Condition "of == NULL", taking false branch.
lib/pkg_editor/src/pkg_editor.c:1480:3:
  2. alloc_arg: "deflateInit_" allocates memory that is stored into "z_info.strm.state".
lib/pkg_editor/src/pkg_editor.c:1482:3:
  3. path: Condition "ret != 0", taking true branch.
lib/pkg_editor/src/pkg_editor.c:1486:5:
  4. leaked_storage: Variable "z_info" going out of scope leaks the storage "z_info.strm.state" points to.
```
Fixes:
```
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:111:5:
  Type: Check of thread-shared field evades lock acquisition (LOCK_EVASION)

lib/acl_threadsupport/test/acl_threadsupport_test.cpp:106:9:
  1. thread1_checks_field: Thread1 uses the value read from static field "threadtest_state" in the condition "threadtest_state == 2". It sees that the condition is false. Control is switched to Thread2.
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:106:9:
  2. thread2_checks_field: Thread2 uses the value read from static field "threadtest_state" in the condition "threadtest_state == 2". It sees that the condition is false.
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:110:5:
  3. thread2_acquires_lock: Thread2 acquires lock "mymutex".
lib/acl_threadsupport/src/acl_threadsupport.c:100:42:
  3.1. lock: "pthread_mutex_lock" locks "mutex".
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:111:5:
  4. thread2_modifies_field: Thread2 sets "threadtest_state" to a new value. Note that this write can be reordered at runtime to occur before instructions that do not access this field within this locked region. After Thread2 leaves the critical section, control is switched back to Thread1.
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:110:5:
  5. thread1_acquires_lock: Thread1 acquires lock "mymutex".
lib/acl_threadsupport/src/acl_threadsupport.c:100:42:
  5.1. lock: "pthread_mutex_lock" locks "mutex".
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:111:5:
  6. thread1_overwrites_value_in_field: Thread1 sets "threadtest_state" to a new value. Now the two threads have an inconsistent view of "threadtest_state" and updates to fields correlated with "threadtest_state" may be lost.
lib/acl_threadsupport/test/acl_threadsupport_test.cpp:106:9:
  7. use_same_locks_for_read_and_modify: Guard the modification of "threadtest_state" and the read used to decide whether to modify "threadtest_state" with the same set of locks.
```
Fixes:
```
include/acl_thread.h:121:7:
  Type: Rule of three (RULE_OF_ZERO_THREE_FIVE)

include/acl_thread.h:121:7:
  rule_of_three_violation: Class "acl_suspend_lock_guard" has a user definition for at least one special function (copy constructor, copy assignment, destructor) but not all.  If one of these functions requires a user definition then the others likely do as well.
include/acl_thread.h:121:7:
  remediation: Add user-definition for a copy constructor.
include/acl_thread.h:121:7:
  remediation: Add user-definition for a copy assignment operator.
include/acl_thread.h:126:3:
  destructor: User-defined destructor.

include/acl_types.h:362:7:
  Type: Rule of three (RULE_OF_ZERO_THREE_FIVE)

include/acl_types.h:362:7:
  rule_of_three_violation: Class "acl_device_program_info_t" has a user definition for at least one special function (copy constructor, copy assignment, destructor) but not all.  If one of these functions requires a user definition then the others likely do as well.
include/acl_types.h:362:7:
  remediation: Add user-definition for a copy constructor.
include/acl_types.h:362:7:
  remediation: Add user-definition for a copy assignment operator.
src/acl_device_program_info.cpp:29:28:
  destructor: User-defined destructor.
```
This also aligns with CppUTest change cpputest/cpputest@37735cc

Fixes:
```
lib/CppUTest/include/CppUTest/Failure.h:72:7:
  Type: Rule of three (RULE_OF_ZERO_THREE_FIVE)

lib/CppUTest/include/CppUTest/Failure.h:72:7:
  rule_of_three_violation: Class "EqualsFailure" has a user definition for at least one special function (copy constructor, copy assignment, destructor) but not all.  If one of these functions requires a user definition then the others likely do as well.
lib/CppUTest/include/CppUTest/Failure.h:80:2:
  copy_ctor: User-defined copy constructor.
lib/CppUTest/include/CppUTest/Failure.h:81:17:
  copy_assign: User-defined copy assignment operator.
lib/CppUTest/include/CppUTest/Failure.h:72:7:
  remediation: Add user-definition for a destructor.
```
@sophimao sophimao marked this pull request as ready for review August 21, 2024 17:00
@sophimao sophimao requested a review from mendell27 August 21, 2024 17:00
@sophimao sophimao merged commit 9a3204e into intel:main Aug 21, 2024
20 checks passed
@sophimao sophimao deleted the coverity-fixes branch August 21, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants