diff mbox

[2/2] rtlwifi: fix static checker warning of dereferencing freed memory

Message ID 20170711013313.3478-3-Larry.Finger@lwfinger.net (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Larry Finger July 11, 2017, 1:33 a.m. UTC
From: Ping-Ke Shih <pkshih@realtek.com>

Patch c76ab8e75442 ("rtlwifi: Fill ap_num field by driver") leads to the
following static checker warning:

	drivers/net/wireless/realtek/rtlwifi/base.c:1741 rtl_scan_list_expire()
	error: dereferencing freed memory 'entry'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: c76ab8e75442 ("rtlwifi: Fill ap_num field by driver")
Cc: Stable <stable@vger.kernel.org> # 4.12+
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/realtek/rtlwifi/base.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index d7a1e2d2d529..7074aee35a11 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1805,13 +1805,13 @@  void rtl_scan_list_expire(struct ieee80211_hw *hw)
 		if (jiffies_to_msecs(jiffies - entry->age) < 180000)
 			continue;
 
+		RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
+			 "BSSID=%pM is expire in scan list (total=%d)\n",
+			 entry->bssid, rtlpriv->scan_list.num - 1);
+
 		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);
 	}
 
 	spin_unlock_irqrestore(&rtlpriv->locks.scan_list_lock, flags);