Commit b6553c71 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jakub Kicinski

net: dm9051: Fix use after free in dm9051_loop_tx()

This code dereferences "skb" after calling dev_kfree_skb().

Fixes: 2dc95a4d ("net: Add dm9051 driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220221105440.GA10045@kiliSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a0b92e05
...@@ -845,17 +845,19 @@ static int dm9051_loop_tx(struct board_info *db) ...@@ -845,17 +845,19 @@ static int dm9051_loop_tx(struct board_info *db)
while (!skb_queue_empty(&db->txq)) { while (!skb_queue_empty(&db->txq)) {
struct sk_buff *skb; struct sk_buff *skb;
unsigned int len;
skb = skb_dequeue(&db->txq); skb = skb_dequeue(&db->txq);
if (skb) { if (skb) {
ntx++; ntx++;
ret = dm9051_single_tx(db, skb->data, skb->len); ret = dm9051_single_tx(db, skb->data, skb->len);
len = skb->len;
dev_kfree_skb(skb); dev_kfree_skb(skb);
if (ret < 0) { if (ret < 0) {
db->bc.tx_err_counter++; db->bc.tx_err_counter++;
return 0; return 0;
} }
ndev->stats.tx_bytes += skb->len; ndev->stats.tx_bytes += len;
ndev->stats.tx_packets++; ndev->stats.tx_packets++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment