From: Michael S. Tsirkin Date: Thu, 26 Dec 2013 13:32:55 +0000 (+0200) Subject: virtio_net: don't leak memory or block when too many frags X-Git-Tag: firefly_0821_release~3679^2~3090 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fcd8e312578603626f0d78084d7ec2e444489aa4;p=firefly-linux-kernel-4.4.55.git virtio_net: don't leak memory or block when too many frags We leak an skb when there are too many frags, we also stop processing the packet in the middle, the result is almost sure to be loss of networking. Reported-by: Michael Dalton Acked-by: Michael Dalton Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ec0e9f236ff0..68692af1f488 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -341,7 +341,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, if (i >= MAX_SKB_FRAGS) { pr_debug("%s: packet too long\n", skb->dev->name); skb->dev->stats.rx_length_errors++; - return NULL; + goto err_frags; } page = virtqueue_get_buf(rq->vq, &len); if (!page) { @@ -362,6 +362,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, err_skb: give_pages(rq, page); while (--num_buf) { +err_frags: buf = virtqueue_get_buf(rq->vq, &len); if (unlikely(!buf)) { pr_debug("%s: rx error: %d buffers missing\n",