summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2013-06-23 17:26:58 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-28 16:25:56 -0700
commit2b01eeeaa363dc4cd5e6d9efd962ac55cc3d5d48 (patch)
treeecf80cffe34acd5c73e4a1a1927b5f5cc41a72a1 /drivers
parentdabed30c3f3af3afd343ad33e3fa0b741ffdebb3 (diff)
downloadlinux-3.10-2b01eeeaa363dc4cd5e6d9efd962ac55cc3d5d48.tar.gz
linux-3.10-2b01eeeaa363dc4cd5e6d9efd962ac55cc3d5d48.tar.bz2
linux-3.10-2b01eeeaa363dc4cd5e6d9efd962ac55cc3d5d48.zip
macvtap: fix recovery from gup errors
[ Upstream commit 4c7ab054ab4f5d63625508ed6f8a607184cae7c2 ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/macvtap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index b99c418d6b2..bc5bf4014f7 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -534,8 +534,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]);
}
truesize = size * PAGE_SIZE;
skb->data_len += len;