Skip to content

Commit

Permalink
kvm: kvm_destroy_vm_debugfs(): check debugfs_stat_data pointer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luiz Capitulino authored and bonzini committed Sep 16, 2016
1 parent 3e3f502 commit 9d5a1dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9d5a1dc

Please sign in to comment.