Skip to contentSkip to conversation

KVM: selftests: Fix kvm_vm_free() in cr4_cpuid_sync and vmx_tsc_adjust tests

PATCH Applied Thomas Huth 2 participants 2 messages Aug 26, 2021 – Sep 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: selftests: Fix kvm_vm_free() in cr4_cpuid_sync and vmx_tsc_adjust tests

The kvm_vm_free() statement here is currently dead code, since the loop in front of it can only be left with the "goto done" that jumps right after the kvm_vm_free(). Fix it by swapping the locations of the "done" label and the kvm_vm_free().

---
 tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 3 +--
 tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +1 -2
index f40fd097cb35..6f6fd189dda3 100644
@@ -109,8 +109,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	kvm_vm_free(vm);
-
 done:
+	kvm_vm_free(vm);
 	return 0;
 }
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +1 -1
index 7e33a350b053..e683d0ac3e45 100644
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	kvm_vm_free(vm);
 done:
+	kvm_vm_free(vm);
 	return 0;
 }
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw
Quoted 31 lines · Thomas Huth

The kvm_vm_free() statement here is currently dead code, since the loop in front of it can only be left with the "goto done" that jumps right after the kvm_vm_free(). Fix it by swapping the locations of the "done" label and the kvm_vm_free().

---
  tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 3 +--
  tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c | 2 +-
  2 files changed, 2 insertions(+), 3 deletions(-)
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +1 -2
index f40fd097cb35..6f6fd189dda3 100644
@@ -109,8 +109,7 @@ int main(int argc, char *argv[])
  		}
  	}
 
-	kvm_vm_free(vm);
-
  done:
+	kvm_vm_free(vm);
  	return 0;
  }
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +0 -0
index 7e33a350b053..e683d0ac3e45 100644

tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c int main(int argc, char *argv[]) · line 167

Quoted 8 lines
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c +1 -1
@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
  		}
  	}
 
-	kvm_vm_free(vm);
  done:
+	kvm_vm_free(vm);
  	return 0;
  }

Queued, thanks.

Paolo