===
kvm_coalesced_mmio_init() keeps to hold the addresses of a coalesced mmio
ring page and dev even after it has freed them.
Also, if this function fails, though it must be rare, it seems to be
suggesting the system's serious state.
This patch changes the error handling for this function to fix these issues.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
---
virt/kvm/coalesced_mmio.c | 2 ++
virt/kvm/kvm_main.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletions(-)
@@ -119,8 +119,10 @@ int kvm_coalesced_mmio_init(struct kvm *kvm)
return ret;
out_free_dev:
+ kvm->coalesced_mmio_dev = NULL;
kfree(dev);
out_free_page:
+ kvm->coalesced_mmio_ring = NULL;
__free_page(page);
out_err:
return ret;
@@ -419,7 +419,9 @@ static struct kvm *kvm_create_vm(void)
list_add(&kvm->vm_list, &vm_list);
spin_unlock(&kvm_lock);
#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
- kvm_coalesced_mmio_init(kvm);
+ r = kvm_coalesced_mmio_init(kvm);
+ if (r < 0)
+ goto out_err;
#endif
out:
return kvm;