diff --git a/src/network.c b/src/network.c index 65557e41..7bc97121 100644 --- a/src/network.c +++ b/src/network.c @@ -198,6 +198,9 @@ void network_disconnected(struct network *network) network_settings_close(network); l_queue_clear(network->blacklist, NULL); + + if (network->provisioning_hidden) + station_hide_network(network->station, network); } /* First 64 entries calculated by 1 / pow(n, 0.3) for n >= 1 */ @@ -983,9 +986,6 @@ void network_connect_failed(struct network *network, bool in_handshake) l_queue_destroy(network->secrets, eap_secret_info_free); network->secrets = NULL; - - if (network->provisioning_hidden) - station_hide_network(network->station, network); } static bool hotspot_info_matches(struct network *network, diff --git a/src/station.c b/src/station.c index d68175a7..2d85054c 100644 --- a/src/station.c +++ b/src/station.c @@ -1616,12 +1616,6 @@ static void station_reset_connection_state(struct station *station) if (!network) return; - if (station->state == STATION_STATE_CONNECTED || - station->state == STATION_STATE_CONNECTING || - station->state == STATION_STATE_CONNECTING_AUTO || - station->state == STATION_STATE_ROAMING) - network_disconnected(network); - station_roam_state_clear(station); /* Refresh the ordered network list */ @@ -1639,6 +1633,17 @@ static void station_reset_connection_state(struct station *station) IWD_NETWORK_INTERFACE, "Connected"); l_dbus_object_remove_interface(dbus, netdev_get_path(station->netdev), IWD_STATION_DIAGNOSTIC_INTERFACE); + + /* + * Perform this step last since calling network_disconnected() might + * result in the removal of the network (for example if provisioning + * a new hidden network fails with an incorrect pasword). + */ + if (station->state == STATION_STATE_CONNECTED || + station->state == STATION_STATE_CONNECTING || + station->state == STATION_STATE_CONNECTING_AUTO || + station->state == STATION_STATE_ROAMING) + network_disconnected(network); } static void station_disassociated(struct station *station)