ath9k: move the max rx buffer size check to ath9k_rx_accept()
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 4 Nov 2009 23:11:05 +0000 (15:11 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 11 Nov 2009 22:09:08 +0000 (17:09 -0500)
While at it flip the order, seems easier to read and also
add some better description as to why we do this check.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/recv.c

index 48ff77255d2fd4db21ac6f10a6355ccec6d01b27..16ed9292c805b30a874cc192a86b242b9bea5a4f 100644 (file)
@@ -105,6 +105,13 @@ static bool ath9k_rx_accept(struct ath_common *common,
 
        if (!rx_stats->rs_datalen)
                return false;
+        /*
+         * rs_status follows rs_datalen so if rs_datalen is too large
+         * we can take a hint that hardware corrupted it, so ignore
+         * those frames.
+         */
+       if (rx_stats->rs_datalen > common->rx_bufsize)
+               return false;
 
        if (rx_stats->rs_more) {
                /*
@@ -801,10 +808,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
                if (flush)
                        goto requeue;
 
-               /* The status portion of the descriptor could get corrupted. */
-               if (common->rx_bufsize < rx_stats->rs_datalen)
-                       goto requeue;
-
                if (!ath_rx_prepare(common, hw, skb, rx_stats,
                                    rxs, &decrypt_error))
                        goto requeue;