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

net: ethernet: SP7021: fix a use after free of skb->len

The netif_receive_skb() function frees "skb" so store skb->len before
it is freed.

Fixes: fd3040b9 ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YoUuy4iTjFAcSn03@kiliSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f01cdcf8
...@@ -29,6 +29,7 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget) ...@@ -29,6 +29,7 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget)
u32 mask; u32 mask;
int port; int port;
u32 cmd; u32 cmd;
u32 len;
/* Process high-priority queue and then low-priority queue. */ /* Process high-priority queue and then low-priority queue. */
for (queue = 0; queue < RX_DESC_QUEUE_NUM; queue++) { for (queue = 0; queue < RX_DESC_QUEUE_NUM; queue++) {
...@@ -63,10 +64,11 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget) ...@@ -63,10 +64,11 @@ int spl2sw_rx_poll(struct napi_struct *napi, int budget)
skb_put(skb, pkg_len - 4); /* Minus FCS */ skb_put(skb, pkg_len - 4); /* Minus FCS */
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
skb->protocol = eth_type_trans(skb, comm->ndev[port]); skb->protocol = eth_type_trans(skb, comm->ndev[port]);
len = skb->len;
netif_receive_skb(skb); netif_receive_skb(skb);
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += skb->len; stats->rx_bytes += len;
/* Allocate a new skb for receiving. */ /* Allocate a new skb for receiving. */
new_skb = netdev_alloc_skb(NULL, comm->rx_desc_buff_size); new_skb = netdev_alloc_skb(NULL, comm->rx_desc_buff_size);
......
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