Commit 28b441e24088081c1e213139d1303b451a34a4f4

Authored by Radim Krčmář
Committed by Gleb Natapov
1 parent 72f857950f

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: Radim Krčmář <rkrcmar@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

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

... ... @@ -101,8 +101,11 @@
101 101 typeof(*work), queue);
102 102 cancel_work_sync(&work->work);
103 103 list_del(&work->queue);
104   - if (!work->done) /* work was canceled */
  104 + if (!work->done) { /* work was canceled */
  105 + mmdrop(work->mm);
  106 + kvm_put_kvm(vcpu->kvm); /* == work->vcpu->kvm */
105 107 kmem_cache_free(async_pf_cache, work);
  108 + }
106 109 }
107 110  
108 111 spin_lock(&vcpu->async_pf.lock);