virtio-net: free bufs correctly on invalid packet length
authorMichael Dalton <mwdalton@google.com>
Thu, 5 Dec 2013 21:14:05 +0000 (13:14 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Dec 2013 21:31:43 +0000 (16:31 -0500)
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>
drivers/net/virtio_net.c

index c2937644342899639640db23ee451c68fcc06afd..d208f860498106013913211183baa39a37f33982 100644 (file)
@@ -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;