Commit e9214638 authored by Jason Wang's avatar Jason Wang Committed by Ben Hutchings

macvtap: zerocopy: put page when fail to get all requested user pages

commit 02ce04bb upstream.

When get_user_pages_fast() fails to get all requested pages, we could not use
kfree_skb() to free it as it has not been put in the skb fragments. So we need
to call put_page() instead.
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 14180f50
...@@ -530,9 +530,11 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from, ...@@ -530,9 +530,11 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT; size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
num_pages = get_user_pages_fast(base, size, 0, &page[i]); num_pages = get_user_pages_fast(base, size, 0, &page[i]);
if ((num_pages != size) || if ((num_pages != size) ||
(num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags)) (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags)) {
/* put_page is in skb free */ for (i = 0; i < num_pages; i++)
put_page(page[i]);
return -EFAULT; return -EFAULT;
}
truesize = size * PAGE_SIZE; truesize = size * PAGE_SIZE;
skb->data_len += len; skb->data_len += len;
skb->len += len; skb->len += len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment