From 66b73262dffe4b9955ee4e64f438fe1ee2a8f101 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 19 May 2021 09:56:59 -0500 Subject: [PATCH] station: Check return of network_bss_select network_bss_select can return NULL if no suitable BSSes are found, or if all of them are blacklisted. Make sure to skip the network if this happens. --- src/station.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/station.c b/src/station.c index a46140c2..5fb3a03d 100644 --- a/src/station.c +++ b/src/station.c @@ -177,17 +177,19 @@ static void station_autoconnect_next(struct station *station) const char *ssid = network_get_ssid(network); struct scan_bss *bss = network_bss_select(network, false); - l_debug("Considering autoconnecting to BSS '%s' with SSID: %s," - " freq: %u, rank: %u, strength: %i", - util_address_to_string(bss->addr), ssid, + l_debug("autoconnect: Trying SSID: %s", ssid); + + if (!bss) { + l_debug("autoconnect: No suitable BSSes found"); + continue; + } + + l_debug("autoconnect: '%s' freq: %u, rank: %u, strength: %i", + util_address_to_string(bss->addr), bss->frequency, bss->rank, bss->signal_strength); - if (blacklist_contains_bss(bss->addr)) - continue; - r = network_autoconnect(network, bss); - if (!r) { station_enter_state(station, STATION_STATE_CONNECTING); @@ -200,7 +202,8 @@ static void station_autoconnect_next(struct station *station) return; } else - l_debug("Failed to autoconnect to %s (%d)", ssid, r); + l_debug("autoconnect: network_autoconnect: %s (%d)", + strerror(-r), r); } }