Guard the default netifs against being created twice - #3526
Conversation
IsWifiInitialised is set at the very end of NF_ESP32_InitaliseWifi(), while several returns sit between the netif creation and that assignment - a failing esp_wifi_init(), esp_wifi_set_mode(), esp_wifi_start() or the AP configuration block. After such a failure the netifs exist but the module still considers itself uninitialised, so the next call re-enters the same branch and creates a second default netif for the same interface: the first one is leaked and esp_netif refuses to attach the second. Create them only when the stored pointer is still NULL. NF_ESP32_DeinitWifi() sets both back to NULL, so a clean de-init followed by an init still creates them.
|
Warning Review limit reachedNext included review available in 32 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
josesimoes
left a comment
There was a problem hiding this comment.
The fix looks OK. Just remove the verbose comment. THe reasoning is perfectly explained in the PR comments where it belongs.
|
Comments removed in f5c7aa4 — the reasoning stays in the PR description. |
|
@coderabbitai review |
|
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Description
NULL.Motivation and Context
IsWifiInitialisedis set at the very end ofNF_ESP32_InitaliseWifi(), while severalreturnstatements sit between the netif creation and that assignment - a failingesp_wifi_init(),esp_wifi_set_mode(),esp_wifi_start()or the AP configuration block. After such a failure the netifs exist but the module still considers itself uninitialised, so the next call re-enters the same branch and creates a second default netif for the same interface. The first one is leaked and esp_netif refuses to attach the second.NF_ESP32_DeinitWifi()already sets both pointers back toNULL, so a clean de-init followed by an init still creates them.How Has This Been Tested?
main.Types of changes
Checklist