linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [RFC 3/6] mac80211: Check for NULL in get-ethtool-stats logic.
Date: Wed, 12 Dec 2012 13:54:52 -0800	[thread overview]
Message-ID: <1355349295-30960-3-git-send-email-greearb@candelatech.com> (raw)
In-Reply-To: <1355349295-30960-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

In an earlier version of this code, testing found that sometimes
either sta wasn't found or sta->sdata was NULL.  This caused
crashes of course.  So, add checks with WARN_ON_ONCE to
catch these.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 net/mac80211/cfg.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 5c61677..1e6dcc3 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -599,7 +599,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
 	if (sdata->vif.type == NL80211_IFTYPE_STATION) {
 		sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
 
-		if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
+		if (sta == NULL || WARN_ON_ONCE(sta->sdata == NULL)
+		    || WARN_ON(sta->sdata->dev != dev))
 			goto do_survey;
 
 		i = 0;
@@ -625,7 +626,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
 	} else {
 		list_for_each_entry(sta, &local->sta_list, list) {
 			/* Make sure this station belongs to the proper dev */
-			if (sta->sdata->dev != dev)
+			if (WARN_ON_ONCE(sta->sdata == NULL) ||
+			    sta->sdata->dev != dev)
 				continue;
 
 			i = 0;
-- 
1.7.3.4


  parent reply	other threads:[~2012-12-12 21:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 21:54 [RFC 1/6] ath9k: Report txerr-filtered errors in debugfs greearb
2012-12-12 21:54 ` [RFC 2/6] wifi: Don't spam logs with 'Found new beacon' messages greearb
2012-12-12 22:08   ` Johannes Berg
2012-12-12 22:15     ` Ben Greear
2012-12-12 22:17       ` Johannes Berg
2012-12-12 22:20         ` Johannes Berg
2012-12-12 22:24           ` Johannes Berg
2012-12-13 20:31             ` Luis R. Rodriguez
2012-12-12 21:54 ` greearb [this message]
2012-12-12 22:02   ` [RFC 3/6] mac80211: Check for NULL in get-ethtool-stats logic Johannes Berg
2012-12-12 22:11     ` Ben Greear
2012-12-12 21:54 ` [RFC 4/6] mac80211: Allow disabling SGI-20 greearb
2012-12-12 22:06   ` Johannes Berg
2012-12-12 22:08     ` Ben Greear
2012-12-13  0:58     ` Ben Greear
2012-12-12 21:54 ` [RFC 5/6] ath9k: Report rx-crc-errors in ethtool stats greearb
2012-12-12 21:54 ` [RFC 6/6] ath9k: Allow using ath9k-rate-control without forcing it greearb

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=1355349295-30960-3-git-send-email-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-wireless@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).