Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6db3f5c authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

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: default avatarJuan Quintela <quintela@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 73a99f08
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -646,8 +646,9 @@ static int set_bit_to_user(int nr, void __user *addr)
	int bit = nr + (log % PAGE_SIZE) * 8;
	int bit = nr + (log % PAGE_SIZE) * 8;
	int r;
	int r;
	r = get_user_pages_fast(log, 1, 1, &page);
	r = get_user_pages_fast(log, 1, 1, &page);
	if (r)
	if (r < 0)
		return r;
		return r;
	BUG_ON(r != 1);
	base = kmap_atomic(page, KM_USER0);
	base = kmap_atomic(page, KM_USER0);
	set_bit(bit, base);
	set_bit(bit, base);
	kunmap_atomic(base, KM_USER0);
	kunmap_atomic(base, KM_USER0);