Skip to contentSkip to conversation

ar9170: fix read & write outside array bounds

PATCH In review Christian Lamparter 2 participants 2 messages Aug 9, 2009 – Aug 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ar9170: fix read & write outside array bounds

From: Dan Carpenter <[email protected]>

queue == __AR9170_NUM_TXQ would cause a bug on the next line.

found by Smatch ( http://repo.or.cz/w/smatch.git ).

---

drivers/net/wireless/ath/ar9170/main.c +3 -2
index 4fc389a..ea8c941 100644
@@ -2458,13 +2458,14 @@ static int ar9170_conf_tx(struct ieee80211_hw *hw, u16 queue,
 	int ret;
 
 	mutex_lock(&ar->mutex);
-	if ((param) && !(queue > __AR9170_NUM_TXQ)) {
+	if (queue < __AR9170_NUM_TXQ) {
 		memcpy(&ar->edcf[ar9170_qos_hwmap[queue]],
 		       param, sizeof(*param));
 
 		ret = ar9170_set_qos(ar);
-	} else
+	} else {
 		ret = -EINVAL;
+	}
 
 	mutex_unlock(&ar->mutex);
 	return ret;
#1 lore raw
Quoted 22 lines · Christian Lamparter

From: Dan Carpenter <[email protected]>

queue == __AR9170_NUM_TXQ would cause a bug on the next line.

found by Smatch ( http://repo.or.cz/w/smatch.git ).

---

drivers/net/wireless/ath/ar9170/main.c +1 -1
index 4fc389a..ea8c941 100644
@@ -2458,13 +2458,14 @@ static int ar9170_conf_tx(struct ieee80211_hw *hw, u16 queue,
 	int ret;
 
 	mutex_lock(&ar->mutex);
-	if ((param) && !(queue > __AR9170_NUM_TXQ)) {
+	if (queue < __AR9170_NUM_TXQ) {
 		memcpy(&ar->edcf[ar9170_qos_hwmap[queue]],

drivers/net/wireless/ath/ar9170/main.c static int ar9170_conf_tx(struct ieee80211_hw *hw, u16 queue, · line 2471

Quoted 10 lines
drivers/net/wireless/ath/ar9170/main.c +2 -1
 		       param, sizeof(*param));
 
 		ret = ar9170_set_qos(ar);
-	} else
+	} else {
 		ret = -EINVAL;
+	}
 
 	mutex_unlock(&ar->mutex);
 	return ret;

The p54 version of this patch used hw->queues instead of a constant. Wouldn't that be better here?

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.