]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SEV: Goto an existing error label if charging misc_cg for an ASID fails
authorSean Christopherson <seanjc@google.com>
Tue, 10 Mar 2026 23:48:29 +0000 (16:48 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 9 Apr 2026 19:00:24 +0000 (12:00 -0700)
Dedup a small amount of cleanup code in SEV ASID allocation by reusing
an existing error label.

No functional change intended.

Link: https://patch.msgid.link/20260310234829.2608037-22-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c

index 1567d01ef464e72726eae0196099409034b70e89..734e5206fbf9c8458f9b6b05c5562fd4fc00e8df 100644 (file)
@@ -289,14 +289,11 @@ static int sev_asid_new(struct kvm_sev_info *sev, unsigned long vm_type)
        if (min_asid > max_asid)
                return -ENOTTY;
 
-       WARN_ON(sev->misc_cg);
+       WARN_ON_ONCE(sev->misc_cg);
        sev->misc_cg = get_current_misc_cg();
        ret = sev_misc_cg_try_charge(sev);
-       if (ret) {
-               put_misc_cg(sev->misc_cg);
-               sev->misc_cg = NULL;
-               return ret;
-       }
+       if (ret)
+               goto e_put_cg;
 
        asid = sev_alloc_asid(min_asid, max_asid);
        if (asid > max_asid) {
@@ -306,8 +303,10 @@ static int sev_asid_new(struct kvm_sev_info *sev, unsigned long vm_type)
 
        sev->asid = asid;
        return 0;
+
 e_uncharge:
        sev_misc_cg_uncharge(sev);
+e_put_cg:
        put_misc_cg(sev->misc_cg);
        sev->misc_cg = NULL;
        return ret;