linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, Ping-Ke Shih <pkshih@realtek.com>,
	Stable <stable@vger.kernel.org>,
	Larry Finger <Larry.Finger@lwfinger.net>
Subject: [PATCH 2/2] rtlwifi: fix static checker warning of dereferencing freed memory
Date: Mon, 10 Jul 2017 20:33:13 -0500	[thread overview]
Message-ID: <20170711013313.3478-3-Larry.Finger@lwfinger.net> (raw)
In-Reply-To: <20170711013313.3478-1-Larry.Finger@lwfinger.net>

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 --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);
-- 
2.12.3

      parent reply	other threads:[~2017-07-11  1:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11  1:33 [PATCH 0/2] rtlwifi: Fix two static errors Larry Finger
2017-07-11  1:33 ` [PATCH 1/2] rtlwifi: fix static checker warning of uninitialized symbol Larry Finger
2017-07-28 15:34   ` [1/2] " Kalle Valo
2017-07-11  1:33 ` Larry Finger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170711013313.3478-3-Larry.Finger@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).