Skip to content

RDKB-65853: Fixing coverity issue#1249

Open
bharathivelp wants to merge 1 commit into
rdkcentral:developfrom
bharathivelp:fix/pattern5_6
Open

RDKB-65853: Fixing coverity issue#1249
bharathivelp wants to merge 1 commit into
rdkcentral:developfrom
bharathivelp:fix/pattern5_6

Conversation

@bharathivelp

Copy link
Copy Markdown
Contributor

Reason for change: Fixing coverity issues.
Test Procedure: Build should be successful and the regression test should also succeed
Risks: Low
Priority: P1
Signed-off-by: Velpula_Bharathi@comcast.com

Copilot AI review requested due to automatic review settings July 6, 2026 15:02
@bharathivelp
bharathivelp requested a review from a team as a code owner July 6, 2026 15:02

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.

Pull request overview

This PR targets Coverity-reported issues by tightening resource cleanup in WiFi monitor/app scheduler flows, primarily around task creation/update error paths and timer task cancellation.

Changes:

  • Adds a common failure path in coordinator_create_task() to cancel the collector task and free associated structures.
  • Adjusts provider insertion/update error handling and key duplication flow in stats coordinator logic.
  • Frees scheduler timer task arguments in WHIX and LEVL when canceling scheduled work.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
source/stats/wifi_monitor.c Adds failure cleanup logic for coordinator task creation/update and makes free_provider_list file-local.
source/apps/whix/wifi_whix.c Frees scheduler timer task args when canceling WHIX timers.
source/apps/levl/wifi_levl.c Frees scheduler timer task args when canceling LEVL timers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/stats/wifi_monitor.c Outdated
Comment thread source/stats/wifi_monitor.c Outdated
Comment thread source/apps/whix/wifi_whix.c
Comment thread source/apps/whix/wifi_whix.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread source/stats/wifi_monitor.c
Comment thread source/stats/wifi_monitor.c
Copilot AI review requested due to automatic review settings July 9, 2026 10:25

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread source/stats/wifi_monitor.c Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 10:40

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread source/stats/wifi_monitor.c
Comment thread source/stats/wifi_monitor.c
Copilot AI review requested due to automatic review settings July 9, 2026 11:22

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread source/stats/wifi_monitor.c
Comment thread source/stats/wifi_monitor.c
Comment thread source/apps/levl/wifi_levl.c
Copilot AI review requested due to automatic review settings July 10, 2026 12:15

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

Comment thread source/apps/whix/wifi_whix.c
Comment thread source/apps/whix/wifi_whix.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/apps/levl/wifi_levl.c
Comment thread source/stats/wifi_monitor.c
Comment thread source/stats/wifi_monitor.c
Copilot AI review requested due to automatic review settings July 13, 2026 06:53

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

source/stats/wifi_monitor.c:5415

  • On hash_map_put() failure, the function returns without cancelling the collector timer or freeing the collector/provider_list, leaving an orphan scheduled task and leaking the collector element. Also note hash_map_put() currently frees the key/data on some failure paths (source/utils/collection.c:175-183) but not others (e == NULL), making ownership ambiguous and risking double-free/leaks at call sites like this. Consider standardizing hash_map_put() to never free caller-owned data/key on failure (or always free on all failures) and then route this error to the common fail: cleanup (including freeing key_copy/provider_elem as appropriate).
    if (hash_map_put((*collector_elem)->provider_list, key_copy, provider_elem) != 0) {
        wifi_util_error_print(WIFI_MON, "%s:%d: hash_map_put failed\n", __func__,__LINE__);
        coordinator_free_provider_elem(&provider_elem);
        return RETURN_ERR;
    }

Comment thread source/stats/wifi_monitor.c
Comment thread source/stats/wifi_monitor.c
Copilot AI review requested due to automatic review settings July 13, 2026 10:32

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

source/stats/wifi_monitor.c:5414

  • On hash_map_put() failure, this function returns without cancelling the already-created collector timer task or freeing (*collector_elem)->provider_list, which can leak resources / leave orphaned scheduled work. Also, hash_map_put() may free both key and data internally on some failure paths (source/utils/collection.c:175-183), so the current error handling risks either leaking key_copy (if hash_map_put fails before owning it) or double-freeing provider_elem (if hash_map_put freed it). Consider aligning ownership semantics: either change hash_map_put() to never free data on failure, or add a variant that doesn't free, and then switch this branch to a single cleanup path (e.g., goto fail) that reliably cancels the collector task and tears down the provider list.
    if (hash_map_put((*collector_elem)->provider_list, key_copy, provider_elem) != 0) {
        wifi_util_error_print(WIFI_MON, "%s:%d: hash_map_put failed\n", __func__,__LINE__);
        coordinator_free_provider_elem(&provider_elem);
        return RETURN_ERR;
    }

Comment thread source/apps/levl/wifi_levl.c
Reason for change: Fixing coverity issues.
Test Procedure: Build should be successful and the regression test should also succeed
Risks: Low
Priority: P1
Signed-off-by: Velpula_Bharathi@comcast.com
Copilot AI review requested due to automatic review settings July 14, 2026 06: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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

source/stats/wifi_monitor.c:5414

  • hash_map_put() failure currently returns without cancelling the already-scheduled collector task or freeing the partially built collector/provider structures. This can leave a dangling scheduled task (arg points to collector_elem) and leak memory. Consider using a failure path that reliably tears down the collector task and provider list; also avoid relying on hash_map_put()'s failure cleanup (it may free(data) internally on some paths).
    if (hash_map_put((*collector_elem)->provider_list, key_copy, provider_elem) != 0) {
        wifi_util_error_print(WIFI_MON, "%s:%d: hash_map_put failed\n", __func__,__LINE__);
        coordinator_free_provider_elem(&provider_elem);
        return RETURN_ERR;
    }

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants