summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGokul K <gokul02k@gmail.com>2026-08-11 10:30:28 +0530
committerSean Christopherson <seanjc@google.com>2026-09-11 09:35:46 -0700
commit434c50e703c5aa24b0409a06f2ec1fc4040788b0 (patch)
treea3e3f97c1e7e00e6b8b51203101fa9c787067fac
parent622a09f6deb53f8dd95d6b6482cf080997a0836a (diff)
downloadlinux-next-434c50e703c5aa24b0409a06f2ec1fc4040788b0.tar.gz
linux-next-434c50e703c5aa24b0409a06f2ec1fc4040788b0.zip
KVM: selftests: Free the VM when the SEV smoke test's guest completes
test_sev() returns directly out of the UCALL_DONE case rather than leaving the loop, so the plain-SEV path skips the kvm_vm_free() at the end of the function. The SEV-ES path is unaffected; it breaks out of the loop and frees the VM correctly. main() invokes test_sev() once per supported SEV VM type, so a full run leaks a VM and its file descriptors. Nothing fails today because the process exits shortly afterwards, which is presumably why this was not noticed, but the leak also means the plain-SEV path never exercises VM teardown. Use a goto so UCALL_DONE joins the existing exit path. A plain break would only leave the switch statement and spin the loop again. Fixes: be250ff437fa ("KVM: selftests: Add a basic SEV smoke test") Signed-off-by: Gokul K <gokul02k@gmail.com> Link: https://patch.msgid.link/20260811050029.530698-2-gokul02k@gmail.com Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--tools/testing/selftests/kvm/x86/sev_smoke_test.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
index bf27b6187afa..19f76f7d8ca6 100644
--- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
+++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
@@ -178,7 +178,7 @@ static void test_sev(void *guest_code, u32 type, u64 policy)
case UCALL_SYNC:
continue;
case UCALL_DONE:
- return;
+ goto done;
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
default:
@@ -187,6 +187,7 @@ static void test_sev(void *guest_code, u32 type, u64 policy)
}
}
+done:
kvm_vm_free(vm);
}