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

Commit 53eac7a8 authored by Peter Xu's avatar Peter Xu Committed by Paolo Bonzini
Browse files

KVM: Fix kvm_clear_dirty_log_protect off-by-(minus-)one



Just imaging the case where num_pages < BITS_PER_LONG, then the loop
will be skipped while it shouldn't.

Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
Fixes: 2a31b9db
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4ddc9204
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1264,8 +1264,8 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm,
		return -EFAULT;

	spin_lock(&kvm->mmu_lock);
	for (offset = log->first_page,
	     i = offset / BITS_PER_LONG, n = log->num_pages / BITS_PER_LONG; n--;
	for (offset = log->first_page, i = offset / BITS_PER_LONG,
		 n = DIV_ROUND_UP(log->num_pages, BITS_PER_LONG); n--;
	     i++, offset += BITS_PER_LONG) {
		unsigned long mask = *dirty_bitmap_buffer++;
		atomic_long_t *p = (atomic_long_t *) &dirty_bitmap[i];