On 24/10/19 04:59, Junaid Shahid wrote: > AFAICT the kvm->users_count is already 0 before kvm_arch_destroy_vm() > is called from kvm_destroy_vm() in the normal case. Yes: if (refcount_dec_and_test(&kvm->users_count)) kvm_destroy_vm(kvm); where | int atomic_inc_and_test(atomic_t *v); | int atomic_dec_and_test(atomic_t *v); | | These two routines increment and decrement by 1, respectively, the | given atomic counter. They return a boolean indicating whether the | resulting counter value was zero or not. > So there really > shouldn't be any arch that does a kvm_put_kvm() inside > kvm_arch_destroy_vm(). I think it might be better to keep the > kvm_arch_destroy_vm() call after the refcount_set() to be consistent > with the normal path. I agree, so I am applying Jim's patch. If anything, we may want to WARN if the refcount is not 1 before the refcount_set. Paolo