Jason Wang
2021-Sep-17 08:34 UTC
[PATCH net] 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 <xuanzhuo at linux.alibaba.com> Fixes: fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom") Signed-off-by: Jason Wang <jasowang at redhat.com> --- drivers/net/virtio_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 271d38c1d9f8..79bd2585ec6b 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; } -- 2.25.1
Xuan Zhuo
2021-Sep-18 01:56 UTC
[PATCH net] virtio-net: fix pages leaking when building skb in big mode
On Fri, 17 Sep 2021 16:34:06 +0800, Jason Wang <jasowang at redhat.com> wrote:> 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 at linux.alibaba.com> > Fixes: fb32856b16ad ("virtio-net: page_to_skb() use build_skb when there's sufficient tailroom") > Signed-off-by: Jason Wang <jasowang at redhat.com>LGTM Reviewed-by: Xuan Zhuo <xuanzhuo at linux.alibaba.com> Thanks.> --- > drivers/net/virtio_net.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 271d38c1d9f8..79bd2585ec6b 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; > } > > -- > 2.25.1 >