Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a82ad8c authored by Jimmy Chen's avatar Jimmy Chen
Browse files

Wifi: fix bug during WIFI HAL stop

In WifiChip::invalidateAndRemoveDependencies, the
iterator was not implemented correctly as it was
deleting objects while iterating. This could cause
the entire WIFI HAL to be restarted when disabling
WIFI.

Bug: 146922967
Test: atest VtsHalWifiV1_0TargetTest VtsHalWifiNanV1_0TargetTest VtsHalWifiApV1_0TargetTest \
            VtsHalWifiV1_1TargetTest \
            VtsHalWifiV1_2TargetTest VtsHalWifiNanV1_2TargetTest \
            VtsHalWifiV1_3TargetTest \
            VtsHalWifiApV1_4TargetTest VtsHalWifiNanV1_4TargetTest VtsHalWifiRttV1_4TargetTest
Change-Id: Id86f1a662684467d3b86a79b271144ac3055d0a0
parent d4d6796b
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -681,9 +681,10 @@ void WifiChip::invalidateAndRemoveAllIfaces() {

void WifiChip::invalidateAndRemoveDependencies(
    const std::string& removed_iface_name) {
    for (const auto& nan_iface : nan_ifaces_) {
    for (auto it = nan_ifaces_.begin(); it != nan_ifaces_.end();) {
        auto nan_iface = *it;
        if (nan_iface->getName() == removed_iface_name) {
            invalidateAndClear(nan_ifaces_, nan_iface);
            nan_iface->invalidate();
            for (const auto& callback : event_cb_handler_.getCallbacks()) {
                if (!callback
                         ->onIfaceRemoved(IfaceType::NAN, removed_iface_name)
@@ -691,11 +692,19 @@ void WifiChip::invalidateAndRemoveDependencies(
                    LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
                }
            }
            it = nan_ifaces_.erase(it);
        } else {
            ++it;
        }
    }
    for (const auto& rtt : rtt_controllers_) {

    for (auto it = rtt_controllers_.begin(); it != rtt_controllers_.end();) {
        auto rtt = *it;
        if (rtt->getIfaceName() == removed_iface_name) {
            invalidateAndClear(rtt_controllers_, rtt);
            rtt->invalidate();
            it = rtt_controllers_.erase(it);
        } else {
            ++it;
        }
    }
}