[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/16] i386: Never free migration blocker objects instead of some

From: Markus Armbruster
Subject: [PATCH 06/16] i386: Never free migration blocker objects instead of sometimes
Date: Tue, 20 Jul 2021 14:53:58 +0200

invtsc_mig_blocker has static storage duration.  When a CPU with
certain features is initialized, and invtsc_mig_blocker is still null,
we add a migration blocker and store it in invtsc_mig_blocker.

The object is freed when migrate_add_blocker() fails, leaving
invtsc_mig_blocker dangling.  It is not freed on later failures.

Same for hv_passthrough_mig_blocker and hv_no_nonarch_cs_mig_blocker.

All failures are actually fatal, so whether we free or not doesn't
really matter, except as bad examples to be copied / imitated.

Clean this up in a minimal way: never free these blocker objects.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
 target/i386/kvm/kvm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 59ed8327ac..8e1bb905ca 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1423,7 +1423,6 @@ static int hyperv_init_vcpu(X86CPU *cpu)
         ret = migrate_add_blocker(hv_passthrough_mig_blocker, &local_err);
         if (local_err) {
-            error_free(hv_passthrough_mig_blocker);
             return ret;
@@ -1438,7 +1437,6 @@ static int hyperv_init_vcpu(X86CPU *cpu)
         ret = migrate_add_blocker(hv_no_nonarch_cs_mig_blocker, &local_err);
         if (local_err) {
-            error_free(hv_no_nonarch_cs_mig_blocker);
             return ret;
@@ -1878,7 +1876,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
             r = migrate_add_blocker(invtsc_mig_blocker, &local_err);
             if (local_err) {
-                error_free(invtsc_mig_blocker);
                 return r;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]