Commit d6db3f5c11dc7ed5712d5d5682aa34025ee5248e

Authored by Michael S. Tsirkin
1 parent 73a99f0830

vhost: fix get_user_pages_fast error handling

get_user_pages_fast returns number of pages on success, negative value
on failure, but never 0. Fix vhost code to match this logic.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/vhost/vhost.c
... ... @@ -646,8 +646,9 @@
646 646 int bit = nr + (log % PAGE_SIZE) * 8;
647 647 int r;
648 648 r = get_user_pages_fast(log, 1, 1, &page);
649   - if (r)
  649 + if (r < 0)
650 650 return r;
  651 + BUG_ON(r != 1);
651 652 base = kmap_atomic(page, KM_USER0);
652 653 set_bit(bit, base);
653 654 kunmap_atomic(base, KM_USER0);