Skip to content

Commit

Permalink
mwifiex: Fix an issue spotted by KASAN
Browse files Browse the repository at this point in the history
When an association command is sent to firmware but the process is
killed before the command response arrives, driver will try to
access bss_desc which is already freed. This issue is fixed by
checking return value of bss_start.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Ganapathi Bhat authored and Kalle Valo committed Jun 29, 2016
1 parent 08aba42 commit 4699fc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/join.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
const u8 *ie_ptr;
struct ieee80211_ht_operation *assoc_resp_ht_oper;

if (!priv->attempted_bss_desc) {
mwifiex_dbg(priv->adapter, ERROR,
"ASSOC_RESP: failed, association terminated by host\n");
goto done;
}

assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params;

cap_info = le16_to_cpu(assoc_rsp->cap_info_bitmap);
Expand Down Expand Up @@ -1270,6 +1276,12 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
u16 cmd = le16_to_cpu(resp->command);
u8 result;

if (!priv->attempted_bss_desc) {
mwifiex_dbg(priv->adapter, ERROR,
"ADHOC_RESP: failed, association terminated by host\n");
goto done;
}

if (cmd == HostCmd_CMD_802_11_AD_HOC_START)
result = start_result->result;
else
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
if (bss_desc)
kfree(bss_desc->beacon_buf);
kfree(bss_desc);

if (ret < 0)
priv->attempted_bss_desc = NULL;

return ret;
}

Expand Down

0 comments on commit 4699fc3

Please sign in to comment.