Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The identified resource leaks are addressed without unresolved review issues.
Review effort: Lite
Findings: None
What changed in this PR
Fixes JSON and buffer memory leaks in update_default_oem_configs() when WPS device_type validation fails.
Changes:
- Deletes the parsed JSON object on the error path.
- Frees the allocated configuration buffer before returning.
| File | Description |
|---|---|
source/dml/tr_181/sbapi/wifi_hostapd_glue.c |
Adds cleanup for JSON and buffer resources on validation failure. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RDKBDEV-3532: Fix JSON and buffer memory leak in update_default_oem_configs() Problem: The function does not release the parsed JSON object and allocated data buffer when the device_type validation fails, resulting in memory leaks. Fix: Add cJSON_Delete(json) and free(data) before returning from the device_type validation error path. Signed-off-by: Yashodha KB <yakshagowda37@gmail.com>
tinaelizabeth84
force-pushed
the
RDKBDEV-3532-resource-leak
branch
from
October 6, 2026 14:18
e2d7d2b to
263e89e
Compare
Contributor
🔨 Build summaryCommit Banana Pi R4 - MLO — build success
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue:
update_default_oem_configs() allocates a JSON object using cJSON_Parse() and a data buffer using malloc(). On the device_type validation error path, the function returns without releasing these resources, causing memory leaks.
Steps to Reproduce:
Expected Behavior:
The parsed JSON object and allocated data buffer should be properly released before the function returns on the error path.
Fix:
Add cJSON_Delete(json) and free(data) before the return in the device_type validation error path.
Acceptance Criteria:
1.json is deleted on the device_type validation error path.
2.data allocated using malloc() is freed on the same error path.
3.Existing cleanup paths remain unchanged.
4.No JSON or heap memory leak remains in update_default_oem_configs().
5.Existing functionality is not affected.