[PATCH 2/2] KVM: LoongArch: selftests: Free the VM when the PMU test skips

From: Gokul K

Date: Mon Nov 23 2026 - 05:07:52 EST


main() creates the VM before asking whether it has the PMU feature, and
when it does not, returns KSFT_SKIP directly. That skips the done: label
through which every other exit frees the VM. Set ret and jump there
instead.

Fixes: 11c840192768 ("KVM: LoongArch: selftests: Add basic PMU event counting test")
Signed-off-by: Gokul K <gokul02k@xxxxxxxxx>
---
tools/testing/selftests/kvm/loongarch/pmu_test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/loongarch/pmu_test.c b/tools/testing/selftests/kvm/loongarch/pmu_test.c
index ec3fefb9ea97..c9dd3cf5de06 100644
--- a/tools/testing/selftests/kvm/loongarch/pmu_test.c
+++ b/tools/testing/selftests/kvm/loongarch/pmu_test.c
@@ -176,7 +176,8 @@ int main(int argc, char *argv[])
pr_info("PMU is enabled in VM\n");
} else {
print_skip("PMU not enabled by VM config\n");
- return KSFT_SKIP;
+ ret = KSFT_SKIP;
+ goto done;
}

while (1) {
--
2.54.0