mt76: mt7663u: fix potential memory leak in mcu message handler
authorSean Wang <sean.wang@mediatek.com>
Tue, 7 Jul 2020 19:16:47 +0000 (03:16 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 21 Jul 2020 17:01:18 +0000 (19:01 +0200)
Fix potential memory leak in mcu message handler on error condition.

Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support")
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c

index 54885ad..39cd7dd 100644 (file)
@@ -34,7 +34,6 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
 
        ret = mt76u_bulk_msg(&dev->mt76, skb->data, skb->len, NULL,
                             1000, ep);
-       dev_kfree_skb(skb);
        if (ret < 0)
                goto out;
 
@@ -43,6 +42,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
 
 out:
        mutex_unlock(&mdev->mcu.mutex);
+       dev_kfree_skb(skb);
 
        return ret;
 }