net: hns3: free the pending skb when clean RX ring
authorPeng Li <lipeng321@huawei.com>
Sun, 14 Apr 2019 01:47:45 +0000 (09:47 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 14 Apr 2019 20:47:35 +0000 (13:47 -0700)
If there is pending skb in RX flow when close the port, and the
pending buffer is not cleaned, the new packet will be added to
the pending skb when the port opens again, and the first new
packet has error data.

This patch cleans the pending skb when clean RX ring.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index a67dfdd..9233438 100644 (file)
@@ -3960,6 +3960,13 @@ static int hns3_clear_rx_ring(struct hns3_enet_ring *ring)
                ring_ptr_move_fw(ring, next_to_use);
        }
 
+       /* Free the pending skb in rx ring */
+       if (ring->skb) {
+               dev_kfree_skb_any(ring->skb);
+               ring->skb = NULL;
+               ring->pending_buf = 0;
+       }
+
        return 0;
 }