提交 28b441e2 编写于 作者: R Radim Krčmář 提交者: Gleb Natapov

kvm: free resources after canceling async_pf

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: NRadim Krčmář <rkrcmar@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 72f85795
...@@ -101,9 +101,12 @@ void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu) ...@@ -101,9 +101,12 @@ 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);
while (!list_empty(&vcpu->async_pf.done)) { while (!list_empty(&vcpu->async_pf.done)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册