Skip to content

RDKCOM-5675: RDKBDEV-3532 Fix JSON and buffer memory leak in update_default_oem_configs() - #1467

Open
Yashu37 wants to merge 2 commits into
rdkcentral:developfrom
Yashu37:RDKBDEV-3532-resource-leak
Open

Yashu37 wants to merge 2 commits into
rdkcentral:developfrom
Yashu37:RDKBDEV-3532-resource-leak

Conversation

@Yashu37

@Yashu37 Yashu37 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

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:

  1. Invoke update_default_oem_configs() with a valid configuration file.
  2. Provide a configuration where the WPS device_type is missing or invalid.
  3. Trigger the device_type validation failure.
  4. Observe that the function returns without deleting the parsed JSON object and freeing the allocated data buffer.

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.

Copilot AI lite review requested due to automatic review settings September 26, 2026 07:08
@Yashu37
Yashu37 requested a review from a team as a code owner September 26, 2026 07:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@pradeeptakdas pradeeptakdas changed the title RDKBDEV-3532: Fix JSON and buffer memory leak in update_default_oem_configs() RDKCOM-5675: RDKBDEV-3532 Fix JSON and buffer memory leak in update_default_oem_configs() Sep 28, 2026
@AkhilaReddyK7 AkhilaReddyK7 added the community contribution Contributions from community. label Sep 28, 2026
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
tinaelizabeth84 force-pushed the RDKBDEV-3532-resource-leak branch from e2d7d2b to 263e89e Compare October 6, 2026 14:18
Copilot AI lite review requested due to automatic review settings October 6, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The validation error path now releases both allocated resources, with no unresolved issues.

Review effort: Lite
Findings: None

@mateuszCieslak-GL mateuszCieslak-GL added the static-analysis Static-analysis findings (Coverity etc.). label Oct 13, 2026
Copilot AI lite review requested due to automatic review settings October 22, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The reviewed error path now releases both allocated resources, with no unresolved blocking issues.

No open issues 🎉

Review effort: Lite

@github-actions

Copy link
Copy Markdown
Contributor

🔨 Build summary

Commit 9558793 · Build Check #5765

Banana Pi R4 - MLO — build success

⚠️ OneWifi warnings: 0

Raspberry Pi — build success

⚠️ OneWifi warnings: 0


🔬 Diff-scoped checks (changed lines only)

🔎 clang-tidy: no findings on changed lines, best-effort only (1 file(s) did not compile)

ℹ️ 1 changed file(s) are only covered by a best-effort clang-tidy run.

🚦 gcc diff-gate: clean on changed lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community contribution Contributions from community. static-analysis Static-analysis findings (Coverity etc.).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants