Skip to content

Commit

Permalink
net: dm9051: Fix use after free in dm9051_loop_tx()
Browse files Browse the repository at this point in the history
This code dereferences "skb" after calling dev_kfree_skb().

Fixes: 2dc95a4 ("net: Add dm9051 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220221105440.GA10045@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Dan Carpenter authored and Jakub Kicinski committed Feb 22, 2022
1 parent a0b92e0 commit b6553c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/davicom/dm9051.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,17 +845,19 @@ static int dm9051_loop_tx(struct board_info *db)

while (!skb_queue_empty(&db->txq)) {
struct sk_buff *skb;
unsigned int len;

skb = skb_dequeue(&db->txq);
if (skb) {
ntx++;
ret = dm9051_single_tx(db, skb->data, skb->len);
len = skb->len;
dev_kfree_skb(skb);
if (ret < 0) {
db->bc.tx_err_counter++;
return 0;
}
ndev->stats.tx_bytes += skb->len;
ndev->stats.tx_bytes += len;
ndev->stats.tx_packets++;
}

Expand Down

0 comments on commit b6553c7

Please sign in to comment.