diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index 186b32745159..49f1894ee807 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -1232,9 +1232,15 @@ wlansap_get_csa_chanwidth_from_phymode(struct sap_context *sap_context, struct ch_params *tgt_ch_params) { enum phy_ch_width ch_width, concurrent_bw = 0; - struct mac_context *mac = sap_get_mac_context(); + struct mac_context *mac; struct ch_params ch_params = {0}; + mac = sap_get_mac_context(); + if (!mac) { + sap_err("Invalid MAC context"); + return CH_WIDTH_20MHZ; + } + if (WLAN_REG_IS_24GHZ_CH_FREQ(chan_freq)) { /* * currently OBSS scan is done in hostapd, so to avoid