Skip to content

Commit

Permalink
mt76: testmode: fix memory leak in mt76_testmode_alloc_skb
Browse files Browse the repository at this point in the history
[ Upstream commit fe2c3b1 ]

Free all pending frames in case of failure in mt76_testmode_alloc_skb
routine

Fixes: 2601dda ("mt76: testmode: add support to send larger packet")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
LorenzoBianconi authored and gregkh committed Jul 14, 2021
1 parent 2e25e8e commit 5b2deeb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/wireless/mediatek/mt76/testmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ int mt76_testmode_alloc_skb(struct mt76_phy *phy, u32 len)
frag_len = MT_TXP_MAX_LEN;

frag = alloc_skb(frag_len, GFP_KERNEL);
if (!frag)
if (!frag) {
mt76_testmode_free_skb(phy);
dev_kfree_skb(head);
return -ENOMEM;
}

__skb_put_zero(frag, frag_len);
head->len += frag->len;
Expand Down

0 comments on commit 5b2deeb

Please sign in to comment.