run_test() returns as soon as it has confirmed that disabling NX huge
pages fails with -EPERM, without freeing the VM created a few lines
earlier.

Jump to the kvm_vm_free() at the end of the function instead, matching
the pattern used for the SEV smoke test in the previous patch.

Fixes: b774da3f2e57 ("KVM: selftests: Test disabling NX hugepages on a VM")
Signed-off-by: Gokul K <[email protected]>
---
 tools/testing/selftests/kvm/x86/nx_huge_pages_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c 
b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c
index 70950067b989..e3b20033a884 100644
--- a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c
@@ -120,7 +120,7 @@ void run_test(int reclaim_period_ms, bool 
disable_nx_huge_pages,
                } else {
                        TEST_ASSERT(r == -1 && errno == EPERM,
                                    "This process should not have permission to 
disable NX huge pages");
-                       return;
+                       goto done;
                }
        }
 
@@ -213,6 +213,7 @@ void run_test(int reclaim_period_ms, bool 
disable_nx_huge_pages,
        check_2m_page_count(vm, disable_nx_huge_pages ? 3 : 2);
        check_split_count(vm, 0);
 
+done:
        kvm_vm_free(vm);
 }
 
-- 
2.54.0



Reply via email to