wifi: ath9k: Fix possible stall on ath9k_txq_list_has_key()
[sfrench/cifs-2.6.git] / drivers / net / wireless / ath / ath9k / main.c
index a4197c14f0a9202b36c073af6a00edb50f005f75..7f9f06ea8a05fdb988decefbfbc35b01d4b7daea 100644 (file)
@@ -850,7 +850,7 @@ static bool ath9k_txq_list_has_key(struct list_head *txq_list, u32 keyix)
 static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)
 {
        struct ath_hw *ah = sc->sc_ah;
-       int i;
+       int i, j;
        struct ath_txq *txq;
        bool key_in_use = false;
 
@@ -868,8 +868,9 @@ static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)
                if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
                        int idx = txq->txq_tailidx;
 
-                       while (!key_in_use &&
-                              !list_empty(&txq->txq_fifo[idx])) {
+                       for (j = 0; !key_in_use &&
+                            !list_empty(&txq->txq_fifo[idx]) &&
+                            j < ATH_TXFIFO_DEPTH; j++) {
                                key_in_use = ath9k_txq_list_has_key(
                                        &txq->txq_fifo[idx], keyix);
                                INCR(idx, ATH_TXFIFO_DEPTH);