From a035c0a0419a9936e043e90a8c6f66f2ab5f08b5 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 8 Jul 2021 16:33:03 +0200 Subject: [PATCH] hostapd: fix use of uninitialized stack variables When a CSA is performed on an 80 MHz channel, hostapd_change_config_freq unconditionally calls hostapd_set_oper_centr_freq_seg0/1_idx with seg0/1 filled by ieee80211_freq_to_chan. However, if ieee80211_freq_to_chan fails (because the freq is 0 or invalid), seg0/1 remains uninitialized and filled with stack garbage, causing errors such as "hostapd: 80 MHz: center segment 1 configured" Signed-off-by: Felix Fietkau --- src/ap/hostapd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index f6fe8a8a0..2b07a9283 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -3453,7 +3453,7 @@ static int hostapd_change_config_freq(struct hostapd_data *hapd, struct hostapd_freq_params *old_params) { int channel; - u8 seg0, seg1; + u8 seg0 = 0, seg1 = 0; struct hostapd_hw_modes *mode; if (!params->channel) {