Skip to content

Commit

Permalink
virtio-net: free bufs correctly on invalid packet length
Browse files Browse the repository at this point in the history
When a packet with invalid length arrives, ensure that the packet
is freed correctly if mergeable packet buffers and big packets
(GUEST_TSO4) are both enabled.

Signed-off-by: Michael Dalton <mwdalton@google.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Dalton authored and David S. Miller committed Dec 6, 2013
1 parent a328f3a commit 98bfd23
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
pr_debug("%s: short packet %i\n", dev->name, len);
dev->stats.rx_length_errors++;
if (vi->big_packets)
give_pages(rq, buf);
else if (vi->mergeable_rx_bufs)
if (vi->mergeable_rx_bufs)
put_page(virt_to_head_page(buf));
else if (vi->big_packets)
give_pages(rq, buf);
else
dev_kfree_skb(buf);
return;
Expand Down

0 comments on commit 98bfd23

Please sign in to comment.