-
Notifications
You must be signed in to change notification settings - Fork 52
RDKEMW-12282: Fix Coverity identified issues - dobby #405
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses a broad set of Coverity findings across Dobby by tightening thread-safety, fixing resource-handling edge cases, and hardening error paths.
Changes:
- Add/adjust mutex/atomic usage to fix data races and uninitialized state warnings.
- Fix resource cleanup and error-path correctness (fd/wordexp/scandir/remove/chmod, etc.).
- Improve defensive checks (bounds/overflow) and a few logging/formatting issues.
Reviewed changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/source/DobbyUtils.cpp | Adds locking around metadata getters to avoid data races. |
| utils/include/DobbyUtils.h | Makes metadata mutex mutable to support const getters locking. |
| settings/source/Settings.cpp | Frees wordexp_t on error path to avoid leaks. |
| rdkPlugins/Storage/source/RefCountFile.cpp | Adds overflow/error checks in refcount increment. |
| rdkPlugins/Storage/source/LoopMountDetails.cpp | Prevents double-close by resetting fd after close. |
| rdkPlugins/Storage/source/DynamicMountDetails.cpp | Refactors mount destination preparation and cleanup logic. |
| rdkPlugins/OOMCrash/source/OOMCrashPlugin.cpp | Simplifies crash file removal and fixes file creation logging/close. |
| rdkPlugins/Networking/source/NetworkingPlugin.cpp | Initializes plugin member pointer to nullptr. |
| rdkPlugins/Networking/source/NetworkSetup.cpp | Uses operator[] for ruleset insertion to avoid invalid iterators. |
| rdkPlugins/Networking/source/IPAllocator.cpp | Reworks directory existence/creation logic for IP store. |
| rdkPlugins/Minidump/source/AnonymousFile.cpp | Treats non-positive file size as invalid/empty with clearer logging. |
| rdkPlugins/Logging/source/FileSink.cpp | Initializes file size limit to avoid uninitialized use. |
| rdkPlugins/IONMemory/source/IonMemoryPlugin.cpp | Initializes plugin member pointer to nullptr. |
| rdkPlugins/HttpProxy/source/HttpProxyPlugin.cpp | Initializes plugin member pointer to nullptr. |
| rdkPlugins/AppServices/source/AppServicesRdkPlugin.cpp | Initializes plugin config pointer to nullptr. |
| plugins/OpenCDM/source/OpenCDMPlugin.cpp | Removes TOCTOU patterns; makes mounting conditional on chmod/chown success; checks addMount return. |
| plugins/MulticastSockets/source/MulticastSocketsPlugin.cpp | Adds fd error checks; fixes env formatting; uses move on push_back. |
| plugins/EthanLog/source/EthanLogLoop.cpp | Locks around client list clear for thread-safety. |
| plugins/EthanLog/source/EthanLogClient.cpp | Adds bounds checks for field parsing to prevent overruns. |
| plugins/EthanLog/client/cat/ethanlog-cat.cpp | Hardens buffer offset type/checks and fixes switch fallthrough. |
| plugins/Common/source/ServiceMonitor.cpp | Removes explicit unlocks around callbacks/timer path. |
| pluginLauncher/tool/source/Main.cpp | Fixes switch fallthrough in argument parsing. |
| pluginLauncher/lib/source/DobbyRdkPluginUtils.cpp | Initializes exitStatus to a known value in constructors. |
| pluginLauncher/lib/source/DobbyRdkPluginManager.cpp | Adds scandir failure handling and avoids redundant fd close. |
| pluginLauncher/lib/include/DobbyRdkPluginUtils.h | Makes getAnnotations thread-safe by locking and returning a copy. |
| ipcUtils/source/DobbyIpcBus.cpp | Removes redundant manual unlock before notifying/joining. |
| daemon/process/source/Main.cpp | Wraps main in try/catch; fixes parseArgs switch fallthrough. |
| daemon/lib/source/include/DobbyWorkQueue.h | Converts counters/flags to atomics. |
| daemon/lib/source/DobbyWorkQueue.cpp | Adds locking in postWork path for same-thread enqueue. |
| daemon/lib/source/DobbyStats.cpp | Fixes PID logging format/cast. |
| daemon/lib/source/DobbyManager.cpp | Refactors shutdown cleanup iteration; fixes lambda capture/move behavior in hibernation path; adds Coverity annotation. |
| daemon/lib/source/DobbyLogger.cpp | Wraps destructor in try/catch; replaces unsafe strcpy with strncpy. |
| daemon/lib/source/DobbyLogRelay.cpp | Initializes members; replaces unsafe strcpy with strncpy. |
| daemon/lib/source/DobbyContainer.cpp | Initializes restart count member. |
| daemon/lib/source/Dobby.cpp | Improves error handling on async work/reply paths. |
| client/tool/source/Main.cpp | Adds locking around promise fulfillment; removes TOCTOU by using opendir-first approach; fixes parseArgs fallthrough. |
| client/lib/source/DobbyProxy.cpp | Removes redundant manual unlock before notifying/joining. |
| bundle/tool/source/Main.cpp | Wraps main in try/catch; fixes parseArgs fallthrough. |
| bundle/lib/source/DobbyTemplate.cpp | Fixes instance return after unlock; corrects prettyPrint whitespace stripping behavior. |
| bundle/lib/source/DobbySpecConfig.cpp | Initializes vars and adds lock around spec version use. |
| bundle/lib/source/DobbyRootfs.cpp | Replaces access() check with directory open + error-specific handling. |
| bundle/lib/source/DobbyConfig.cpp | Adds lock around printCommand config access. |
| bundle/lib/source/DobbyBundleConfig.cpp | Adds locks to several getters. |
| AppInfrastructure/ReadLine/source/ReadLine.cpp | Fixes format string typo in error message. |
| AppInfrastructure/Public/Common/Notifier.h | Adds Coverity annotation and removes redundant unlock. |
| AppInfrastructure/IpcService/source/sdbus/SDBusIpcService.cpp | Prevents timeout multiplication overflow via casts. |
| AppInfrastructure/Common/source/Timer.cpp | Adds try/catch around cancel in destructor. |
| AppInfrastructure/Common/source/ThreadedDispatcher.cpp | Removes explicit unlocks; rewrites flush logic and adds locking in predicate. |
| AppInfrastructure/Common/include/IDGenerator.h | Replaces rand() with random_device-based seed for initialization. |
| AppInfrastructure/Common/include/ConditionVariable.h | Removes dead/unreachable return after throw. |
Comments suppressed due to low confidence (1)
plugins/Common/source/ServiceMonitor.cpp:205
- onReadyNotification invokes mStateChangeHandler while holding mLock (explicit unlock removed). This risks deadlock/re-entrancy issues and holds the mutex across user callback code. Capture any needed state under lock, unlock, then invoke the handler.
// call the registered handler
if (mStateChangeHandler)
mStateChangeHandler(State::Ready);
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const std::string& DobbyBundleConfig::rootfsPath() const | ||
| { | ||
| std::lock_guard<std::mutex> locker(mLock); | ||
| return mRootfsPath; | ||
| } |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootfsPath() returns a const reference to internal state. Locking inside the getter does not make the returned reference thread-safe after the function returns, and can give a false sense of safety. Prefer returning a copy (std::string) or require the caller to hold the lock for the lifetime of the reference.
| ContainerId id = it->first; | ||
| int32_t descriptor = it->second->descriptor; | ||
| AI_LOG_INFO("Stopping container %s", id.c_str()); | ||
| ++it; | ||
| locker.unlock(); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mLock is unlocked while iterating mContainers, but the iterator 'it' (advanced before unlock) is then reused after relocking. Another thread can erase the element that 'it' points to while the lock is released, leaving 'it' dangling and causing undefined behavior. Avoid carrying iterators across unlock; collect container IDs/descriptors to stop first, or restart iteration after relocking.
| try { | ||
| cancel(); | ||
| } catch (const std::exception& e) { | ||
| } |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timer::~Timer() catches std::exception but ignores it (empty catch block), which can hide real failures during destruction. Either remove the try/catch (cancel() doesn't appear to throw here) or at least log the exception so failures aren't silently swallowed.
| try { | |
| cancel(); | |
| } catch (const std::exception& e) { | |
| } | |
| cancel(); |
Description
RDKEMW-12282: Fix Coverity identified issues - dobby
If there is a corresponding JIRA ticket, please ensure it is in the title of the PR.
Test Procedure
How to test this PR (if applicable)
Type of Change
Requires Bitbake Recipe changes?
meta-rdk-ext/recipes-containers/dobby/dobby.bb) must be modified to support the changes in this PR (beyond updatingSRC_REV)