Skip to contentSkip to conversation

potential null deref in minstrel_ht_update_caps()?

PATCH New Dan Carpenter 2 participants 3 messages Jul 22, 2010 mac80211

lore
Share & tools
lore
#0 lore raw

This is a smatch thing.

net/mac80211/rc80211_minstrel_ht.c +639 minstrel_ht_update_caps(15)
warn: variable dereferenced before check 'sta'

   631          struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
   632          struct ieee80211_local *local = hw_to_local(mp->hw);
   633          u16 sta_cap = sta->ht_cap.cap;
                              ^^^^^^^^^^^^^^^
	Dereferenced here.
   634          int ack_dur;
   635          int stbc;
   636          int i;
   637
   638          /* fall back to the old minstrel for legacy stations */
   639          if (sta && !sta->ht_cap.ht_supported) {
                    ^^^
	Checked here.
   640                  msp->is_ht = false;
   641                  memset(&msp->legacy, 0, sizeof(msp->legacy));

It seems like a bug, but I'm not sure how to deal with it.

regards,
dan carpenter

#1 lore raw

PATCH 1/1 minstrel_ht: remove unnecessary NULL check in minstrel_ht_update_caps

If sta is NULL, we will have problems long before we get here...

---
 net/mac80211/rc80211_minstrel_ht.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +1 -1
index b5ace24..a16694b 100644
@@ -636,7 +636,7 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
 	int i;
 
 	/* fall back to the old minstrel for legacy stations */
-	if (sta && !sta->ht_cap.ht_supported) {
+	if (!sta->ht_cap.ht_supported) {
 		msp->is_ht = false;
 		memset(&msp->legacy, 0, sizeof(msp->legacy));
 		msp->legacy.r = msp->ratelist;
Signature · 1 line
1.7.1.1
#2 lore raw
In reply to Dan Carpenter
Quoted 19 lines · Dan Carpenter

This is a smatch thing.

net/mac80211/rc80211_minstrel_ht.c +639 minstrel_ht_update_caps(15)
warn: variable dereferenced before check 'sta'

   631          struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
   632          struct ieee80211_local *local = hw_to_local(mp->hw);
   633          u16 sta_cap = sta->ht_cap.cap;
                              ^^^^^^^^^^^^^^^
	Dereferenced here.
   634          int ack_dur;
   635          int stbc;
   636          int i;
   637
   638          /* fall back to the old minstrel for legacy stations */
   639          if (sta && !sta->ht_cap.ht_supported) {
                    ^^^
	Checked here.
Quoted 4 lines
   640                  msp->is_ht = false;
   641                  memset(&msp->legacy, 0, sizeof(msp->legacy));

It seems like a bug, but I'm not sure how to deal with it.

I think that sta NULL check is unnecessary there.

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.