Skip to content

Commit

Permalink
mt76: mt7921: fix network buffer leak by txs missing
Browse files Browse the repository at this point in the history
TXS in mt7921 may be forwared to tx_done event. Should try to catch
TXS information in tx_done event as well.

Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
deren authored and nbd168 committed Dec 15, 2021
1 parent 4ed8c91 commit bf105aa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mt7921/mac.c
Expand Up @@ -1150,7 +1150,7 @@ mt7921_mac_add_txs_skb(struct mt7921_dev *dev, struct mt76_wcid *wcid, int pid,
return !!skb;
}

static void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data)
void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data)
{
struct mt7921_sta *msta = NULL;
struct mt76_wcid *wcid;
Expand Down
14 changes: 14 additions & 0 deletions mt7921/mcu.c
Expand Up @@ -418,6 +418,17 @@ mt7921_mcu_low_power_event(struct mt7921_dev *dev, struct sk_buff *skb)
trace_lp_event(dev, event->state);
}

static void
mt7921_mcu_tx_done_event(struct mt7921_dev *dev, struct sk_buff *skb)
{
struct mt7921_mcu_tx_done_event *event;

skb_pull(skb, sizeof(struct mt7921_mcu_rxd));
event = (struct mt7921_mcu_tx_done_event *)skb->data;

mt7921_mac_add_txs(dev, event->txs);
}

static void
mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
{
Expand Down Expand Up @@ -445,6 +456,9 @@ mt7921_mcu_rx_unsolicited_event(struct mt7921_dev *dev, struct sk_buff *skb)
case MCU_EVENT_LP_INFO:
mt7921_mcu_low_power_event(dev, skb);
break;
case MCU_EVENT_TX_DONE:
mt7921_mcu_tx_done_event(dev, skb);
break;
default:
break;
}
Expand Down
27 changes: 27 additions & 0 deletions mt7921/mcu.h
Expand Up @@ -91,6 +91,33 @@ enum {
MCU_EVENT_COREDUMP = 0xf0,
};

struct mt7921_mcu_tx_done_event {
u8 pid;
u8 status;
__le16 seq;

u8 wlan_idx;
u8 tx_cnt;
__le16 tx_rate;

u8 flag;
u8 tid;
u8 rsp_rate;
u8 mcs;

u8 bw;
u8 tx_pwr;
u8 reason;
u8 rsv0[1];

__le32 delay;
__le32 timestamp;
__le32 applied_flag;
u8 txs[28];

u8 rsv1[32];
} __packed;

/* ext event table */
enum {
MCU_EXT_EVENT_RATE_REPORT = 0x87,
Expand Down
1 change: 1 addition & 0 deletions mt7921/mt7921.h
Expand Up @@ -464,4 +464,5 @@ int mt7921s_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct mt76_tx_info *tx_info);
void mt7921s_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e);
bool mt7921s_tx_status_data(struct mt76_dev *mdev, u8 *update);
void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data);
#endif

0 comments on commit bf105aa

Please sign in to comment.