Commit 21820c18 authored by Radim Krčmář's avatar Radim Krčmář Committed by Ben Hutchings

kvm: free resources after canceling async_pf

commit 28b441e2 upstream.

When we cancel 'async_pf_execute()', we should behave as if the work was
never scheduled in 'kvm_setup_async_pf()'.
Fixes a bug when we can't unload module because the vm wasn't destroyed.
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 6d7f02a6
...@@ -101,8 +101,11 @@ void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu) ...@@ -101,8 +101,11 @@ void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu)
typeof(*work), queue); typeof(*work), queue);
cancel_work_sync(&work->work); cancel_work_sync(&work->work);
list_del(&work->queue); list_del(&work->queue);
if (!work->done) /* work was canceled */ if (!work->done) { /* work was canceled */
mmdrop(work->mm);
kvm_put_kvm(vcpu->kvm); /* == work->vcpu->kvm */
kmem_cache_free(async_pf_cache, work); kmem_cache_free(async_pf_cache, work);
}
} }
spin_lock(&vcpu->async_pf.lock); spin_lock(&vcpu->async_pf.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment