Skip to content

Commit

Permalink
rtlwifi: kfree entry until after entry->bssid has been accessed
Browse files Browse the repository at this point in the history
The current code kfree's entry and then dereferences it by accessing
entry->bssid.  Avoid the dereference-after-free by moving the kfree
after the access to entry->bssid.

Detected by CoverityScan, CID#1448600 ("Read from pointer after free")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Colin Ian King authored and Kalle Valo committed Jul 27, 2017
1 parent 4b5dde2 commit d0116f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/wireless/realtek/rtlwifi/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,12 +1735,12 @@ void rtl_scan_list_expire(struct ieee80211_hw *hw)
continue;

list_del(&entry->list);
kfree(entry);
rtlpriv->scan_list.num--;

RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
"BSSID=%pM is expire in scan list (total=%d)\n",
entry->bssid, rtlpriv->scan_list.num);
kfree(entry);
}

spin_unlock_irqrestore(&rtlpriv->locks.scan_list_lock, flags);
Expand Down

0 comments on commit d0116f6

Please sign in to comment.