ACS: Check whether iface->current_mode is NULL before use

This line seemed to trigger SIGSEGV in some code coverage testing cases.
It is not exactly clear how that was possible, but just in case, check
that iface->current_mode is set before using it here.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2023-12-17 00:02:43 +02:00
parent ae20eb1d27
commit 29f38ebcf6

View file

@ -917,7 +917,8 @@ acs_find_ideal_chan_mode(struct hostapd_iface *iface,
/* If the AP is in the 5 GHz or 6 GHz band, lets prefer a less /* If the AP is in the 5 GHz or 6 GHz band, lets prefer a less
* crowded primary channel if one was found in the segment */ * crowded primary channel if one was found in the segment */
if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A && if (iface->current_mode &&
iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
chan != best) { chan != best) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"ACS: promoting channel %d over %d (less interference %Lg/%Lg)", "ACS: promoting channel %d over %d (less interference %Lg/%Lg)",