hostapd: Make sure band selection does not result in NULL dereference

Explicitly check for iface->current_mode before dereferencing it. While
this case may not happen in practice, it is better for the setup
functions to be more careful when doing the initial band selection.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2015-06-01 18:56:19 +03:00 committed by Jouni Malinen
parent dc1a341dec
commit 0980c7face

View file

@ -744,6 +744,9 @@ static int hostapd_is_usable_chan(struct hostapd_iface *iface,
int i; int i;
struct hostapd_channel_data *chan; struct hostapd_channel_data *chan;
if (!iface->current_mode)
return 0;
for (i = 0; i < iface->current_mode->num_channels; i++) { for (i = 0; i < iface->current_mode->num_channels; i++) {
chan = &iface->current_mode->channels[i]; chan = &iface->current_mode->channels[i];
if (chan->chan != channel) if (chan->chan != channel)
@ -805,6 +808,12 @@ hostapd_check_chans(struct hostapd_iface *iface)
static void hostapd_notify_bad_chans(struct hostapd_iface *iface) static void hostapd_notify_bad_chans(struct hostapd_iface *iface)
{ {
if (!iface->current_mode) {
hostapd_logger(iface->bss[0], NULL, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_WARNING,
"Hardware does not support configured mode");
return;
}
hostapd_logger(iface->bss[0], NULL, hostapd_logger(iface->bss[0], NULL,
HOSTAPD_MODULE_IEEE80211, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_WARNING, HOSTAPD_LEVEL_WARNING,