Skip to content

Commit

Permalink
mt76: mt7615: reset token when mac_reset happens
Browse files Browse the repository at this point in the history
Reset token in mt7615_mac_reset_work() to avoid possible leakege.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
ryderlee1110 authored and nbd168 committed Dec 31, 2020
1 parent eacd2d4 commit e4b2330
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
20 changes: 20 additions & 0 deletions mt7615/mac.c
Expand Up @@ -2067,6 +2067,23 @@ void mt7615_dma_reset(struct mt7615_dev *dev)
}
EXPORT_SYMBOL_GPL(mt7615_dma_reset);

void mt7615_tx_token_put(struct mt7615_dev *dev)
{
struct mt76_txwi_cache *txwi;
int id;

spin_lock_bh(&dev->token_lock);
idr_for_each_entry(&dev->token, txwi, id) {
mt7615_txp_skb_unmap(&dev->mt76, txwi);
if (txwi->skb)
dev_kfree_skb_any(txwi->skb);
mt76_put_txwi(&dev->mt76, txwi);
}
spin_unlock_bh(&dev->token_lock);
idr_destroy(&dev->token);
}
EXPORT_SYMBOL_GPL(mt7615_tx_token_put);

void mt7615_mac_reset_work(struct work_struct *work)
{
struct mt7615_phy *phy2;
Expand Down Expand Up @@ -2110,6 +2127,9 @@ void mt7615_mac_reset_work(struct work_struct *work)

mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_PDMA_STOPPED);

mt7615_tx_token_put(dev);
idr_init(&dev->token);

if (mt7615_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) {
mt7615_dma_reset(dev);

Expand Down
2 changes: 1 addition & 1 deletion mt7615/mt7615.h
Expand Up @@ -583,7 +583,7 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct mt76_tx_info *tx_info);

void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e);

void mt7615_tx_token_put(struct mt7615_dev *dev);
void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
struct sk_buff *skb);
void mt7615_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps);
Expand Down
12 changes: 1 addition & 11 deletions mt7615/pci_init.c
Expand Up @@ -160,9 +160,7 @@ int mt7615_register_device(struct mt7615_dev *dev)

void mt7615_unregister_device(struct mt7615_dev *dev)
{
struct mt76_txwi_cache *txwi;
bool mcu_running;
int id;

mcu_running = mt7615_wait_for_mcu_init(dev);

Expand All @@ -172,15 +170,7 @@ void mt7615_unregister_device(struct mt7615_dev *dev)
mt7615_mcu_exit(dev);
mt7615_dma_cleanup(dev);

spin_lock_bh(&dev->token_lock);
idr_for_each_entry(&dev->token, txwi, id) {
mt7615_txp_skb_unmap(&dev->mt76, txwi);
if (txwi->skb)
dev_kfree_skb_any(txwi->skb);
mt76_put_txwi(&dev->mt76, txwi);
}
spin_unlock_bh(&dev->token_lock);
idr_destroy(&dev->token);
mt7615_tx_token_put(dev);

tasklet_disable(&dev->irq_tasklet);

Expand Down

0 comments on commit e4b2330

Please sign in to comment.