[PATCH] KVM: selftests: Fix VM leak in early return

Tharit Tangkijwanichakul posted 1 patch 2 weeks, 5 days ago
tools/testing/selftests/kvm/arm64/external_aborts.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] KVM: selftests: Fix VM leak in early return
Posted by Tharit Tangkijwanichakul 2 weeks, 5 days ago
test_mmio_ease() returns early and skips the call to kvm_vm_free() when
ID_AA64PFR1_EL1 is not available.

Use a goto so that the early return joins the common exit path.

Reported-by: Gokul K <gokul02k@gmail.com>
Link: https://lore.kernel.org/all/20260808081050.408657-1-gokul02k@gmail.com/
Fixes: a90aac553249 ("KVM: arm64: selftests: Test SEAs are taken to SError vector when EASE=1")
Signed-off-by: Tharit Tangkijwanichakul <tharitt97@gmail.com>
---
Tested on a Rock 5B (RK3588). ID_AA64PFR1_EL1.DF2 is not implemented,
so test_mmio_ease() takes the skip path exercised by this fix.
---
 tools/testing/selftests/kvm/arm64/external_aborts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/arm64/external_aborts.c b/tools/testing/selftests/kvm/arm64/external_aborts.c
index d8fe17a6cc59..7836756a38a6 100644
--- a/tools/testing/selftests/kvm/arm64/external_aborts.c
+++ b/tools/testing/selftests/kvm/arm64/external_aborts.c
@@ -339,7 +339,7 @@ static void test_mmio_ease(void)
 	pfr1 = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR1_EL1));
 	if (!SYS_FIELD_GET(ID_AA64PFR1_EL1, DF2, pfr1)) {
 		pr_debug("Skipping %s\n", __func__);
-		return;
+		goto done;
 	}
 
 	/*
@@ -356,6 +356,7 @@ static void test_mmio_ease(void)
 
 	vcpu_inject_sea(vcpu);
 	vcpu_run_expect_done(vcpu);
+done:
 	kvm_vm_free(vm);
 }
 
-- 
2.47.3
Re: [PATCH] KVM: selftests: Fix VM leak in early return
Posted by Marc Zyngier 1 week, 4 days ago
On Sun, 06 Sep 2026 03:41:43 +0000, Tharit Tangkijwanichakul wrote:
> test_mmio_ease() returns early and skips the call to kvm_vm_free() when
> ID_AA64PFR1_EL1 is not available.
> 
> Use a goto so that the early return joins the common exit path.

Applied to next, thanks!

[1/1] KVM: selftests: Fix VM leak in early return
      commit: bb6c7d2bf564cdaa24b14764b7126f5cab45965a

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.