kvm: kvm_destroy_vm_debugfs(): check debugfs_stat_data pointer
authorLuiz Capitulino <lcapitulino@redhat.com>
Wed, 7 Sep 2016 18:47:21 +0000 (14:47 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 16 Sep 2016 14:57:46 +0000 (16:57 +0200)
This make it possible to call kvm_destroy_vm_debugfs() from
kvm_create_vm_debugfs() in error conditions.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c

index a00f8e4..a6e864c 100644 (file)
@@ -559,9 +559,11 @@ static void kvm_destroy_vm_debugfs(struct kvm *kvm)
 
        debugfs_remove_recursive(kvm->debugfs_dentry);
 
-       for (i = 0; i < kvm_debugfs_num_entries; i++)
-               kfree(kvm->debugfs_stat_data[i]);
-       kfree(kvm->debugfs_stat_data);
+       if (kvm->debugfs_stat_data) {
+               for (i = 0; i < kvm_debugfs_num_entries; i++)
+                       kfree(kvm->debugfs_stat_data[i]);
+               kfree(kvm->debugfs_stat_data);
+       }
 }
 
 static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)