kvm_init_debug() runs before several steps that can fail (kvm_vfio_ops_init(), kvm_gmem_init(), kvm_init_virtualization() and misc_register()), but none of the corresponding error labels remove the "kvm" debugfs directory. Any failure after kvm_init_debug() therefore leaks the directory and its stat files for the lifetime of the boot. kvm_exit() already calls debugfs_remove_recursive(kvm_debugfs_dir); add the same at the err_vfio label, whose fall-through covers every path taken after kvm_init_debug(). Fixes: 2b0128127373 ("KVM: Register /dev/kvm as the _very_ last thing during initialization") Signed-off-by: leixiang --- virt/kvm/kvm_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e44c20c04961..d4420ebfd972 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -6559,6 +6559,7 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module) err_gmem: kvm_vfio_ops_exit(); err_vfio: + debugfs_remove_recursive(kvm_debugfs_dir); kvm_async_pf_deinit(); err_async_pf: kvm_irqfd_exit(); -- 2.43.0