Skip to contentSkip to conversation

ath9k: guard "ah->intr_ref_cnt" from going "negative"

PATCH New Viorel Suman 1 participant 1 message Mar 1, 2015 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: guard "ah->intr_ref_cnt" from going "negative"

The counter "ah->intr_ref_cnt" goes into "negative" territory from "ath9k_stop" method by calling "disable_interrupts" method directly, and then - indirectly by calling "ath_prepare_reset" method. The patch guards the counter from going into a "negative" territory.

---
 drivers/net/wireless/ath/ath9k/mac.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/mac.c +18 -5
index bba85d1..9369133 100644
@@ -796,11 +796,24 @@ EXPORT_SYMBOL(ath9k_hw_kill_interrupts);
 
 void ath9k_hw_disable_interrupts(struct ath_hw *ah)
 {
-	if (!(ah->imask & ATH9K_INT_GLOBAL))
-		atomic_set(&ah->intr_ref_cnt, -1);
-	else
-		atomic_dec(&ah->intr_ref_cnt);
-
+	struct ath_common *common = ath9k_hw_common(ah);
+	int rcount;
+
+	if (ah->imask & ATH9K_INT_GLOBAL) {
+		rcount = atomic_read(&ah->intr_ref_cnt);
+		if (rcount < 0) {
+			ath_dbg(common, INTERRUPT,
+				"IER already disabled ref count %d\n", rcount);
+			return;
+		}
+		if (rcount > 0 && !atomic_dec_and_test(&ah->intr_ref_cnt)) {
+			ath_dbg(common, INTERRUPT,
+				"Do not disable IER ref count %d\n",
+				atomic_read(&ah->intr_ref_cnt));
+			return;
+		}
+	}
+	atomic_set(&ah->intr_ref_cnt, -1);
 	ath9k_hw_kill_interrupts(ah);
 }
 EXPORT_SYMBOL(ath9k_hw_disable_interrupts);
Signature · 1 line
2.3.0