13627105546 opened a new pull request, #17870: URL: https://github.com/apache/nuttx/pull/17870
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Fix a race condition in the `wifi_sim` driver that leads to a crash during disconnection. **Issue:** When a process (Process A) initiates a Wi-Fi disconnect, it frees the `wifidev->connected_ap` structure. However, if the Wi-Fi state is not updated immediately, another process (Process B) might attempt to access `wifidev->connected_ap` (e.g., to retrieve RSSI) while the state is still considered `CONNECTED`. This results in an invalid memory access (use-after-free) and causes the simulator to crash. **Fix:** Explicitly update the Wi-Fi state to `WLAN_STA_STATE_DISCONNECTED` *before* freeing `wifidev->connected_ap`. This ensures that other processes check the correct state and avoid accessing the released memory. ## Impact **Impact on user**: Improves the stability of the Wi-Fi simulator by preventing crashes during disconnection, especially in multi-threaded environments or when multiple applications are accessing the network interface. * **Backward compatibility**: Yes. * **New feature**: No, bug fix. ## Testing * **Target**: `sim:wifi` * **Verification**: * Simulated the race condition scenario by disconnecting Wi-Fi while concurrently querying station status. * Verified that the simulator no longer crashes after the fix. * Passed `tools/checkpatch.sh`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
