Skip to content

Commit

Permalink
virtio-net: fix pages leaking when building skb in big mode
Browse files Browse the repository at this point in the history
[ Upstream commit afd92d8 ]

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 <xuanzhuo@linux.alibaba.com>
Fixes: fb32856 ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jasowang authored and gregkh committed Sep 30, 2021
1 parent 9a5ba85 commit f020bb6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/virtio_net.c
Expand Up @@ -435,6 +435,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;
}

Expand Down

0 comments on commit f020bb6

Please sign in to comment.