From: Colin Ian King Date: Fri, 30 Jun 2017 10:08:43 +0000 (+0100) Subject: rtlwifi: kfree entry until after entry->bssid has been accessed X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d0116f6f7b306bc2d1bfc98d7c7c80fe5f468c20;p=openwrt%2Fstaging%2Fblogic.git rtlwifi: kfree entry until after entry->bssid has been accessed 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 Signed-off-by: Kalle Valo --- diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c index e36ee592c660..208f56297a75 100644 --- a/drivers/net/wireless/realtek/rtlwifi/base.c +++ b/drivers/net/wireless/realtek/rtlwifi/base.c @@ -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);