Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/bulkdata/profilexconf.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/bulkdata/profilexconf.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 1011 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/bulkdata/profilexconf.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -47,6 +47,7 @@
static ProfileXConf *singleProfile = NULL;
static pthread_mutex_t plMutex; /* TODO - we can remove plMutex most likely but firseck that CollectAndReport doesn't cause issue */
static pthread_cond_t reuseThread;
static pthread_t reportThread; // This is the thread that runs CollectAndReportXconf function
static bool reportThreadExits = false;

static pid_t xconfReportPid;
Expand Down Expand Up @@ -220,6 +221,11 @@
do
{
T2Info("%s while Loop -- START \n", __FUNCTION__);
if(singleProfile == NULL)
{
T2Error("%s is called with empty profile, profile reload might be in-progress, skip the request\n", __FUNCTION__);
goto reportXconfThreadEnd;
}
profile = singleProfile;
Vector *profileParamVals = NULL;
Vector *grepResultList = NULL;
Expand Down Expand Up @@ -494,7 +500,6 @@
//pthread_mutex_unlock(&plMutex);
reportXconfThreadEnd :
T2Info("%s while Loop -- END \n", __FUNCTION__);
T2Info("%s --out\n", __FUNCTION__);
pthread_cond_wait(&reuseThread, &plMutex);
}
while(initialized);
Expand Down Expand Up @@ -591,7 +596,7 @@
pthread_mutex_lock(&plMutex);
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
pthread_join(singleProfile->reportThread, NULL);
pthread_join(reportThread, NULL);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity issue no longer present as of: undefined

Show issue

Coverity Issue - Data race condition

Accessing "reportThread" without holding lock "plMutex". Elsewhere, "reportThread" is written to with "plMutex" held 1 out of 1 times.

Medium Impact, CWE-366
MISSING_LOCK

reportThreadExits = false;
singleProfile->reportInProgress = false ;
T2Info("Final report is completed, releasing profile memory\n");
Expand Down Expand Up @@ -727,17 +732,7 @@

if(singleProfile->reportInProgress)
{
T2Info("Waiting for CollectAndReport to be complete : %s\n", singleProfile->name);
pthread_mutex_lock(&plMutex);
initialized = false;
T2Info("Sending signal to reuse Thread in CollectAndReportXconf\n");
pthread_cond_signal(&reuseThread);
pthread_mutex_unlock(&plMutex);
pthread_join(singleProfile->reportThread, NULL);
T2Info("reportThread exits and initialising the profile list\n");
reportThreadExits = false;
initialized = true;
singleProfile->reportInProgress = false ;
T2Info("Waiting for CollectAndReportXconf to be complete : %s\n", singleProfile->name);
}

pthread_mutex_lock(&plMutex);
Expand Down Expand Up @@ -906,7 +901,7 @@
}
else
{
reportThreadStatus = pthread_create(&singleProfile->reportThread, NULL, CollectAndReportXconf, NULL);
reportThreadStatus = pthread_create(&reportThread, NULL, CollectAndReportXconf, NULL);
if ( reportThreadStatus != 0 )
{
T2Error("Failed to create report thread with error code = %d !!! \n", reportThreadStatus);
Expand Down
1 change: 0 additions & 1 deletion source/bulkdata/profilexconf.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/bulkdata/profilexconf.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/bulkdata/profilexconf.h' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 78 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/bulkdata/profilexconf.h)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -66,7 +66,6 @@
Vector *topMarkerList;
Vector *cachedReportList;
cJSON *jsonReportObj;
pthread_t reportThread;
GrepSeekProfile *grepSeekProfile; // To store GrepConfig
} ProfileXConf;

Expand Down
Loading