Commit bc0932cf authored by Sean Christopherson's avatar Sean Christopherson
Browse files

KVM: SEV: Goto an existing error label if charging misc_cg for an ASID fails

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: default avatarSean Christopherson <seanjc@google.com>
parent 1d353dae
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -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;