[PATCH 0/3] KVM: selftests: Fix three leaked resources
From: Gokul K
Date: Tue Dec 01 2026 - 04:06:46 EST
Three resource leaks found while auditing the selftests, all on paths
that run normally rather than on error paths.
Patches 1 and 2 are both /dev/sev descriptors. The first is the one that
matters: every SEV VM opens /dev/sev into vm->arch.sev_fd and nothing
ever closes it, because x86 never provided a kvm_arch_vm_release(). arm64 is the only architecture
that overrides that hook today. The second is sev_init2_tests.c opening
the device once per KVM_SEV_INIT2 ioctl and keeping none of them.
Patch 3 is unrelated to SEV: kvm_binary_stats_test.c loses the id string
when the kernel reports no stats descriptors.
Compile-tested and run on an AMD host without SEV, so patches 1 and 2
are compile-tested only - the paths they touch need an SEV-capable
machine. kvm_binary_stats_test passes 4/4 before and after patch 3. Nine
x86 selftests were run with and without patch 1, which touches the
library every x86 test links, and gave identical results:
set_memory_region_test and x86/state_test fail both ways, as this host's
kernel is older than the tree, and x86/kvm_clock_test skips.
Gokul K (3):
KVM: selftests: Close /dev/sev when an SEV VM is released
KVM: selftests: Close the SEV fd opened for each KVM_SEV_INIT2 ioctl
KVM: selftests: Free the stats id string when no stats are defined
tools/testing/selftests/kvm/kvm_binary_stats_test.c | 1 +
tools/testing/selftests/kvm/lib/x86/processor.c | 6 ++++++
tools/testing/selftests/kvm/x86/sev_init2_tests.c | 5 ++++-
3 files changed, 11 insertions(+), 1 deletion(-)
--
2.51.0