Skip to content

Commit

Permalink
macvtap: fix recovery from gup errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael S. Tsirkin authored and David S. Miller committed Jun 25, 2013
1 parent 7e24bfb commit 4c7ab05
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c7ab05

Please sign in to comment.