RDKB-65853: Fixing coverity issue#1249
Conversation
There was a problem hiding this comment.
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.
7b8d2c0 to
3a23acb
Compare
3a23acb to
e949051
Compare
e949051 to
b94c952
Compare
b94c952 to
29da7be
Compare
29da7be to
75a7f5f
Compare
75a7f5f to
40df855
Compare
40df855 to
3aff73f
Compare
There was a problem hiding this comment.
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;
}
3aff73f to
4adbf12
Compare
There was a problem hiding this comment.
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 bothkeyanddatainternally on some failure paths (source/utils/collection.c:175-183), so the current error handling risks either leakingkey_copy(ifhash_map_putfails before owning it) or double-freeingprovider_elem(ifhash_map_putfreed it). Consider aligning ownership semantics: either changehash_map_put()to never freedataon 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;
}
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
4adbf12 to
dd5cb0a
Compare
There was a problem hiding this comment.
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 tocollector_elem) and leak memory. Consider using a failure path that reliably tears down the collector task and provider list; also avoid relying onhash_map_put()'s failure cleanup (it mayfree(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;
}
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