Skip to content

Commit

Permalink
drivers: wifi: Handle interface de-initialization races
Browse files Browse the repository at this point in the history
When the interface is being brought down there can be number of races
conditions till the deletion is properly propagated, so, add NULL checks
to avoid crash.

E.g.,

  * Supplicant can still be deleting keys but interface is already
    removed in the driver
  * Networking stack sending TX packet

Avoiding the races completely will be handled later. As these can happen
till that time, no error logging is added.

Fixes SHEL-1982 partially.

Signed-off-by: Chaitanya Tata <[email protected]>
  • Loading branch information
krish2718 authored and de-nordic committed Sep 15, 2023
1 parent 8e57854 commit 0c01025
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/wifi/nrf700x/osal/fw_if/umac_if/src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,20 @@ static enum wifi_nrf_status umac_event_ctrl_process(struct wifi_nrf_fmac_dev_ctx
struct wifi_nrf_fmac_dev_ctx_def *def_dev_ctx = NULL;
struct wifi_nrf_fmac_priv_def *def_priv = NULL;

def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv);
def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);

if (!fmac_dev_ctx || !event_data) {
wifi_nrf_osal_log_err(fmac_dev_ctx->fpriv->opriv,
"%s: Invalid parameters\n",
__func__);
goto out;
}

def_priv = wifi_fmac_priv(fmac_dev_ctx->fpriv);
def_dev_ctx = wifi_dev_priv(fmac_dev_ctx);

if (!def_priv || !def_dev_ctx) {
goto out;
}

umac_hdr = event_data;
if_id = umac_hdr->ids.wdev_id;
event_num = umac_hdr->cmd_evnt;
Expand Down
4 changes: 4 additions & 0 deletions drivers/wifi/nrf700x/zephyr/src/zephyr_net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ int wifi_nrf_if_send(const struct device *dev,

rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;

if (!rpu_ctx_zep->rpu_ctx) {
goto out;
}

if ((vif_ctx_zep->if_carr_state != WIFI_NRF_FMAC_IF_CARR_STATE_ON) ||
(!vif_ctx_zep->authorized && !is_eapol(pkt))) {
goto out;
Expand Down
7 changes: 7 additions & 0 deletions drivers/wifi/nrf700x/zephyr/src/zephyr_wpa_supp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,13 @@ int wifi_nrf_wpa_supp_set_key(void *if_priv, const unsigned char *ifname, enum w
vif_ctx_zep = if_priv;
rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;

/* Can happen in a positive case where "net if down" is completed, but WPA
* supplicant is still deleting keys.
*/
if (!rpu_ctx_zep->rpu_ctx) {
goto out;
}

memset(&key_info, 0, sizeof(key_info));

if (alg != WPA_ALG_NONE) {
Expand Down

0 comments on commit 0c01025

Please sign in to comment.