Skip to content

RDKEMW-3380 : Evaluate the Deepsleep Scenario for Static and Dynamic method #123

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 39 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f35f973
Update rrdIarmEvents.c
Abhinavpv28 Apr 28, 2025
fdd49a1
Update rrdIarmEvents.c
Abhinavpv28 Apr 28, 2025
6505570
Update rrdIarmEvents.c
Abhinavpv28 Apr 28, 2025
422b923
Update rrdIarmEvents.c
Abhinavpv28 Apr 28, 2025
8858cb6
Update rrdIarmEvents.c
Abhinavpv28 Apr 29, 2025
d4589ae
Update rrdCommon.h
Abhinavpv28 Apr 29, 2025
868225a
Merge pull request #119 from rdkcentral/develop
Abhinavpv28 Apr 29, 2025
a2606db
Update rrdIarmEvents.c
Abhinavpv28 May 1, 2025
e37a84b
Update rrdInterface.h
Abhinavpv28 May 1, 2025
00c08f1
Update rrdCommon.h
Abhinavpv28 May 1, 2025
ef5f023
Update rrdRunCmdThread.c
Abhinavpv28 May 1, 2025
8476824
Update rrdRunCmdThread.c
Abhinavpv28 May 1, 2025
9ff1203
Update rrdRunCmdThread.c
Abhinavpv28 May 2, 2025
f1172a0
Update rrdDynamic.c
Abhinavpv28 May 2, 2025
9e68cdc
Update rrdJsonParser.c
Abhinavpv28 May 2, 2025
6a22aa0
Update rrdCommon.h
Abhinavpv28 May 2, 2025
ae3ae4f
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
bf11204
Update rrdInterface.h
Abhinavpv28 May 2, 2025
541b69e
Update rrdInterface.h
Abhinavpv28 May 2, 2025
f8f0d5a
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
80968de
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
90a9b61
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
af6848b
Update rrdRunCmdThread.c
Abhinavpv28 May 2, 2025
ca65bd1
Update rrdRunCmdThread.c
Abhinavpv28 May 2, 2025
fbaba23
Update rrdRunCmdThread.c
Abhinavpv28 May 2, 2025
d9513ea
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
98e0600
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
d1d7a56
Update rrdIarmEvents.c
Abhinavpv28 May 2, 2025
a17fa5d
Update rrdJsonParser.c
Abhinavpv28 May 3, 2025
559dd27
Update rrdEventProcess.c
Abhinavpv28 May 3, 2025
6043540
Update rrdJsonParser.c
Abhinavpv28 May 3, 2025
d55f52f
Update rrdJsonParser.c
Abhinavpv28 May 3, 2025
c132988
Update rrdJsonParser.c
Abhinavpv28 May 3, 2025
b7176bb
Update rrdEventProcess.c
Abhinavpv28 May 5, 2025
ed11b4e
Update rrdCommon.h
Abhinavpv28 May 6, 2025
92555c6
Merge pull request #122 from rdkcentral/develop
Abhinavpv28 May 9, 2025
738a49b
Update rrdIarmEvents.c
Abhinavpv28 May 9, 2025
761d65f
Update rrdIarmEvents.c
Abhinavpv28 May 9, 2025
b9c4b56
Update rrdIarmEvents.c
Abhinavpv28 May 10, 2025
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
2 changes: 1 addition & 1 deletion src/rrdDynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void RRDRdmManagerDownloadRequest(issueNodeData *pissueStructNode, char *dynJSON
{
#ifdef IARMBUS_SUPPORT
if (isDeepSleepAwakeEvent)
strncpy(msgDataString, paramString, msgDataStringSize);
strncpy(msgDataString, paramString, (msgDataStringSize - strlen(RDM_PKG_SUFFIX)));
else
snprintf(msgDataString, msgDataStringSize, "%s%s", RDM_PKG_PREFIX, pissueStructNode->Node);
#else
Expand Down
16 changes: 5 additions & 11 deletions src/rrdEventProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ static void processIssueType(data_buf *rbuf)
processIssueTypeInStaticProfile(rbuf, pIssueNode);
}
//CID-336989: Resource leak
free(pIssueNode);
}
else
{
Expand Down Expand Up @@ -297,16 +296,11 @@ static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssu
isStaticIssue = findIssueInParsedJSON(pIssueNode, jsonParsed);
if (isStaticIssue)
{
// Issue in Static Profile JSON
// CID 336981: Use after free (USE_AFTER_FREE)
if ( pIssueNode->Node && pIssueNode->subNode )
{
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Issue Data Node: %s and Sub-Node: %s found in Static JSON File %s... \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode, RRD_JSON_FILE);
// CID 336988: Double free (USE_AFTER_FREE)
if (rbuf)
{
checkIssueNodeInfo(pIssueNode, jsonParsed, rbuf, false, NULL); // sanity Check and Get Command List
}
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Issue Data Node: %s and Sub-Node: %s found in Static JSON File %s... \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode, RRD_JSON_FILE);
// CID 336988: Double free (USE_AFTER_FREE)
if(rbuf)
{
checkIssueNodeInfo(pIssueNode, jsonParsed, rbuf, false, NULL); // sanity Check and Get Command List
}
}
else
Expand Down
16 changes: 3 additions & 13 deletions src/rrdIarmEvents.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,14 @@ int RRD_IARM_subscribe()
void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
const PowerController_PowerState_t newState, void* userdata)
{
#if !defined(ENABLE_WEBCFG_FEATURE)
data_buf *sbuf = NULL;
int msgLen = strlen(DEEP_SLEEP_STR) + 1;
#endif
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. currentState =%d, newState = %d\n", __FUNCTION__, __LINE__, currentState, newState);

if ((currentState == POWER_STATE_STANDBY_DEEP_SLEEP &&
newState != POWER_STATE_STANDBY_DEEP_SLEEP))
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received state from Power Manager Current :[%d] New[%d] \n", __FUNCTION__, __LINE__, currentState, newState);
#ifdef ENABLE_WEBCFG_FEATURE
rbusError_t rc = RBUS_ERROR_BUS_ERROR;
rbusValue_t value;
rbusValue_Init(&value);
Expand All @@ -166,26 +163,24 @@ void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
return;
}
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC);
#else
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Copying Message Received to the queue.. \n", __FUNCTION__, __LINE__);
sbuf = (data_buf *)malloc(sizeof(data_buf));
if (!sbuf)
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId %d \n", __FUNCTION__, __LINE__, eventId);
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId \n", __FUNCTION__, __LINE__);
return;
}

RRD_data_buff_init(sbuf, DEEPSLEEP_EVENT_MSG, RRD_DEEPSLEEP_RDM_DOWNLOAD_PKG_INITIATE);
sbuf->mdata = (char *)malloc(msgLen);
if (!sbuf->mdata)
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId %d \n", __FUNCTION__, __LINE__, eventId);
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId \n", __FUNCTION__, __LINE__);
RRD_data_buff_deAlloc(sbuf);
return;
}
strncpy((char *)sbuf->mdata, (const char *)DEEP_SLEEP_STR, msgLen);
RRDMsgDeliver(msqid, sbuf);
#endif
}
else
{
Expand All @@ -207,10 +202,8 @@ void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
IARM_Bus_PWRMgr_EventData_t *eventData = NULL;
#if !defined(ENABLE_WEBCFG_FEATURE)
data_buf *sbuf = NULL;
int msgLen = strlen(DEEP_SLEEP_STR) + 1;
#endif
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. \n", __FUNCTION__, __LINE__);

if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0)
Expand All @@ -223,7 +216,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Event ID found for IARM_BUS_RDK_REMOTE_DEBUGGER_DEEPSLEEP_AWAKE %d \n", __FUNCTION__, __LINE__, eventId);
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received state from Power Manager Current :[%d] New[%d] \n", __FUNCTION__, __LINE__, eventData->data.state.curState, eventData->data.state.newState);
#ifdef ENABLE_WEBCFG_FEATURE
rbusError_t rc = RBUS_ERROR_BUS_ERROR;
rbusValue_t value;
rbusValue_Init(&value);
Expand All @@ -235,7 +227,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
return;
}
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC);
#else
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Copying Message Received to the queue.. \n", __FUNCTION__, __LINE__);
sbuf = (data_buf *)malloc(sizeof(data_buf));
if (!sbuf)
Expand All @@ -254,7 +245,7 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
}
strncpy((char *)sbuf->mdata, (const char *)DEEP_SLEEP_STR, msgLen);
RRDMsgDeliver(msqid, sbuf);
#endif
RRD_data_buff_deAlloc(sbuf);
}
else
{
Expand All @@ -268,7 +259,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Exit.. \n", __FUNCTION__, __LINE__);
}
Copy link

@rdkcmf-jenkins rdkcmf-jenkins May 9, 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 - Resource leak

Variable "sbuf" going out of scope leaks the storage it points to.

High Impact, CWE-404
RESOURCE_LEAK

#endif

/*
* @function _rdmManagerEventHandler
* @brief Receives the RDM Manager event and sends the value as a message in the message-queue
Expand Down
5 changes: 5 additions & 0 deletions src/rrdJsonParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,11 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
ctime = time (NULL);
ltime = localtime (&ctime);
dlen=snprintf(outdir,BUF_LEN_256,"%s%s-DebugReport-",RRD_OUTPUT_DIR,issuestructNode->Node);
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: debug print issuestructNode->Node: %s !!! \n",__FUNCTION__,__LINE__, issuestructNode->Node);
if ((strcmp(issuestructNode->Node, DEEP_SLEEP_STR) == 0)|| (strcmp(issuestructNode->Node, "deepsleep")== 0))
{
isDeepSleepAwakeEventValid = true;
}
strftime (outdir + dlen, sizeof(outdir) - dlen, "%Y-%m-%d-%H-%M-%S", ltime);
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Creating Directory %s for Issue Category to store Output data...\n",__FUNCTION__,__LINE__,outdir);
if (mkdir(outdir,0777) != 0)
Expand Down
Loading