-
Notifications
You must be signed in to change notification settings - Fork 20
Feature/rdkemw 9528 #250
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: feature/test
Are you sure you want to change the base?
Feature/rdkemw 9528 #250
Changes from all commits
6af91a8
ceedca5
f479163
ecf785d
87aaef0
f5dcd39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -892,6 +892,7 @@ void publishReportUploadStatus(char* status) | |||||||||||||||||
| rbusValue_Init(&value); | ||||||||||||||||||
| rbusValue_SetString(value, status); | ||||||||||||||||||
| rbusObject_SetValue(outParams, "UPLOAD_STATUS", value); | ||||||||||||||||||
| rbusValue_Release(value); // FIX: Release value immediately after SetValue to prevent double-free | ||||||||||||||||||
|
||||||||||||||||||
|
|
||||||||||||||||||
| T2Info("Sending response as %s from %s \n", status, __FUNCTION__ ); | ||||||||||||||||||
| err = rbusMethod_SendAsyncResponse(onDemandReportCallBackHandler, RBUS_ERROR_SUCCESS, outParams); | ||||||||||||||||||
|
|
@@ -904,9 +905,8 @@ void publishReportUploadStatus(char* status) | |||||||||||||||||
| T2Info("%s rbusMethod_SendAsyncResponse sent successfully \n", __FUNCTION__); | ||||||||||||||||||
| } | ||||||||||||||||||
| onDemandReportCallBackHandler = NULL; // just a safety cleanup | ||||||||||||||||||
| pthread_mutex_unlock(&asyncMutex); | ||||||||||||||||||
| rbusValue_Release(value); | ||||||||||||||||||
| rbusObject_Release(outParams); | ||||||||||||||||||
| rbusObject_Release(outParams); // FIX: Only release outParams, value is already released above | ||||||||||||||||||
|
||||||||||||||||||
| pthread_mutex_unlock(&asyncMutex); // FIX: Unlock mutex after cleanup to prevent race conditions | ||||||||||||||||||
|
Comment on lines
+908
to
+909
|
||||||||||||||||||
| rbusObject_Release(outParams); // FIX: Only release outParams, value is already released above | |
| pthread_mutex_unlock(&asyncMutex); // FIX: Unlock mutex after cleanup to prevent race conditions | |
| pthread_mutex_unlock(&asyncMutex); // Unlock once shared handler is cleared | |
| rbusObject_Release(outParams); // FIX: Only release outParams, value is already released above |
Copilot
AI
Jan 30, 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.
The mutex unlock has been moved to after resource cleanup, which unnecessarily extends the critical section. The mutex (asyncMutex) protects the shared state onDemandReportCallBackHandler, which is already set to NULL at line 907. The resource cleanup operations (rbusObject_Release) do not need mutex protection and should not be performed while holding the lock. This increases lock contention and could impact performance. The mutex should be unlocked immediately after line 907, before the cleanup operations, as it was in the original code.
| rbusObject_Release(outParams); // FIX: Only release outParams, value is already released above | |
| pthread_mutex_unlock(&asyncMutex); // FIX: Unlock mutex after cleanup to prevent race conditions | |
| pthread_mutex_unlock(&asyncMutex); | |
| rbusObject_Release(outParams); // FIX: Only release outParams, value is already released above |
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.
The comment states "Release value immediately after SetValue to prevent double-free" but this is misleading. There is no double-free issue in the original code - each resource was released exactly once. The actual issue with this change is that releasing the value too early may cause rbusMethod_SendAsyncResponse to reference freed memory, since rbusObject_SetValue likely does not create a copy of the value. The comment should be removed or corrected.