RDKB-62334: Fix Coverity defects (1 file) - #436
Merged
Merged
Conversation
Defect ID: 736257e3-1ee9-4acb-a8b1-7c0b28c99b5c
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is minimal, localized, and correctly restores mutex-state correctness on the pthread_cond_wait() failure path without impacting the success path logic.
Review effort: Lite
Findings: None
What changed in this PR
This PR addresses a Coverity-reported thread-safety defect in the Bulk Data Event Receiver dispatch thread by correctly handling the failure path of pthread_cond_wait() in T2ER_EventDispatchThread.
Changes:
- Ensures
erMutexis explicitly unlocked whenpthread_cond_wait(&erCond, &erMutex)returns a non-zero error code. - Exits the dispatch thread immediately on
pthread_cond_wait()failure to avoid continuing execution under an invalid “wait succeeded” assumption.
| File | Description |
|---|---|
source/bulkdata/t2eventreceiver.c |
Fixes the error path for pthread_cond_wait() by unlocking erMutex before returning from the dispatch thread. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage Summary |
Code Coverage Summary |
Code Coverage Summary |
Code Coverage Summary |
…metry into topic/RDKB-62334
Comment on lines
+286
to
+290
| stopDispatchThread = true; | ||
| pthread_mutex_unlock(&sTDMutex); | ||
| } | ||
| else | ||
| { |
Comment on lines
+575
to
+579
| ret = pthread_detach(erThread); | ||
| if(ret != 0) | ||
| { | ||
| T2Error("%s pthread_detach for erThread failed with error code %d\n", __FUNCTION__, ret); | ||
| } |
Code Coverage Summary |
Code Coverage Summary |
shibu-kv
approved these changes
Sep 30, 2026
Contributor
|
L2 failure are due to infra issues caused by a bad release from native container having below changes : Overriding and merging for now to unblock the progress. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fix for Coverity Defects
Triggered by: dev-user
Fixed Files
source/bulkdata/t2eventreceiver.cFix Summaries
source/bulkdata/t2eventreceiver.cThe fix correctly addresses the BAD_CHECK_OF_WAIT_COND defect in T2ER_EventDispatchThread. In the original code, when pthread_cond_wait() failed (ret != 0), the error was logged but execution fell through to the subsequent code (unlock, sTDMutex lock, re-acquire erMutex) as if the wait had succeeded. This was incorrect because on failure, erMutex is still held by the calling thread (pthread_cond_wait atomically reacquires the mutex before returning, even on error per POSIX), so the mutex must be unlocked before returning. The fix adds a proper unlock of erMutex followed by return NULL in the error branch, which is the correct and minimal fix. The change is minimal (5 lines added), does not introduce new defects, preserves all existing logic in the success path, and correctly handles the mutex state on the error path.
Repository Guidelines Applied
.github/copilot-instructions.md(instruction).github/instructions/c-embedded.instructions.md(instruction).github/skills/thread-safety-analyzer/SKILL.md(skill)Activated skills: thread-safety-analyzer