From: Jason Wang Date: Fri, 17 Sep 2021 08:34:06 +0000 (+0800) Subject: virtio-net: fix pages leaking when building skb in big mode X-Git-Tag: baikal/mips/sdk5.9~10009^2~31 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=b588d91a1de3bfeecfe2075079a86236e8697b94;p=kernel.git virtio-net: fix pages leaking when building skb in big mode We try to use build_skb() if we had sufficient tailroom. But we forget to release the unused pages chained via private in big mode which will leak pages. Fixing this by release the pages after building the skb in big mode. Cc: Xuan Zhuo Fixes: 6acd284c2ed1 ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom") Signed-off-by: Jason Wang Reviewed-by: Xuan Zhuo Signed-off-by: David S. Miller --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 271d38c1d9f80..79bd2585ec6b2 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -423,6 +423,10 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, skb_reserve(skb, p - buf); skb_put(skb, len); + + page = (struct page *)page->private; + if (page) + give_pages(rq, page); goto ok; }