git: 51dfae383bf6 - main - [ath] validate ts_antenna before updating tx statistics

Adrian Chadd adrian at FreeBSD.org
Sat Mar 13 01:33:38 UTC 2021


The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=51dfae383bf6298af9e6d816a78b92b6f34d68be

commit 51dfae383bf6298af9e6d816a78b92b6f34d68be
Author:     Adrian Chadd <adrian at FreeBSD.org>
AuthorDate: 2021-03-13 01:29:09 +0000
Commit:     Adrian Chadd <adrian at FreeBSD.org>
CommitDate: 2021-03-13 01:33:07 +0000

    [ath] validate ts_antenna before updating tx statistics
    
    Right now ts_antenna is either 0 or 1 in each supported HAL so
    this is purely a sanity check.
    
    Later on if I ever get magical free time I may add some extensions
    for the NICs that can have slightly more complicated antenna switches
    for transmit and I'd like this to not bust memory.
---
 sys/dev/ath/if_ath.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 34a9311c834a..0ef10e529dd5 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -4175,6 +4175,11 @@ ath_tx_update_stats(struct ath_softc *sc, struct ath_tx_status *ts,
 
 	if (ts->ts_status == 0) {
 		u_int8_t txant = ts->ts_antenna;
+		/*
+		 * Handle weird/corrupted tx antenna field
+		 */
+		if (txant >= ATH_IOCTL_STATS_NUM_TX_ANTENNA)
+			txant = 0;
 		sc->sc_stats.ast_ant_tx[txant]++;
 		sc->sc_ant_tx[txant]++;
 		if (ts->ts_finaltsi != 0)


More information about the dev-commits-src-main mailing list