diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2013-06-23 16:26:58 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-26 01:17:10 +0200 |
commit | 4c7ab054ab4f5d63625508ed6f8a607184cae7c2 (patch) | |
tree | 63273346588712553b8bece014b124cd2b6196e4 /drivers/net/macvtap.c | |
parent | tun: fix recovery from gup errors (diff) | |
download | linux-4c7ab054ab4f5d63625508ed6f8a607184cae7c2.tar.xz linux-4c7ab054ab4f5d63625508ed6f8a607184cae7c2.zip |
macvtap: fix recovery from gup errors
get user pages might fail partially in macvtap zero copy
mode. To recover we need to put all pages that we got,
but code used a wrong index resulting in double-free
errors.
Reported-by: Brad Hubbard <bhubbard@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvtap.c')
-rw-r--r-- | drivers/net/macvtap.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 59e9605de316..b6dd6a75919a 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c @@ -524,8 +524,10 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from, return -EMSGSIZE; num_pages = get_user_pages_fast(base, size, 0, &page[i]); if (num_pages != size) { - for (i = 0; i < num_pages; i++) - put_page(page[i]); + int j; + + for (j = 0; j < num_pages; j++) + put_page(page[i + j]); return -EFAULT; } truesize = size * PAGE_SIZE; |