Skip to contentSkip to conversation

wifi: ath9k: free clone buffer on fi->bf overwrite in ath_tx_setup_buffer

PATCH In review Rosen Penev 2 participants 2 messages Sep 4 – Sep 11 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: ath9k: free clone buffer on fi->bf overwrite in ath_tx_setup_buffer

ath_clone_txbuf allocates an ath_buf for the last stale subframe of an A-MPDU and stores it in fi->bf. On retransmission, ath_tx_setup_buffer overwrites fi->bf with the newly allocated buffer without freeing the clone, leaking one ath_buf per aggregate retry that enters the clone path.

Clear the clone's references and return it to the free pool before overwriting fi->bf.

Assisted-by opencode:big-pickle
---
 drivers/net/wireless/ath/ath9k/xmit.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/xmit.c +5 -0
index 89930eaf1fd3..b12eb878d5e7 100644
@@ -2264,6 +2264,11 @@ static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
 		return NULL;
 	}
 
+	if (fi->bf) {
+		fi->bf->bf_mpdu = NULL;
+		fi->bf->bf_buf_addr = 0;
+		ath_tx_return_buffer(sc, fi->bf);
+	}
 	fi->bf = bf;
 
 	return bf;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 5 lines · Rosen Penev

ath_clone_txbuf allocates an ath_buf for the last stale subframe of an A-MPDU and stores it in fi->bf. On retransmission, ath_tx_setup_buffer overwrites fi->bf with the newly allocated buffer without freeing the clone, leaking one ath_buf per aggregate retry that enters the clone path.

Huh? No, it doesn't - ath_tx_get_tid_subframe() has this:

		if (!fi->bf)
			bf = ath_tx_setup_buffer(sc, txq, tid, skb);
		else
			bf->bf_state.stale = false;

-Toke