Skip to content

Commit 7353633

Browse files
Etsukatabonzini
authored andcommitted
KVM: x86/xen: Fix eventfd error handling in kvm_xen_eventfd_assign()
Should not call eventfd_ctx_put() in case of error. Fixes: 2fd6df2 ("KVM: x86/xen: intercept EVTCHNOP_send from guests") Reported-by: [email protected] Signed-off-by: Eiichi Tsukata <[email protected]> Message-Id: <[email protected]> [Introduce new goto target instead. - Paolo] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 696db30 commit 7353633

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/x86/kvm/xen.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,18 +1666,18 @@ static int kvm_xen_eventfd_assign(struct kvm *kvm,
16661666
case EVTCHNSTAT_ipi:
16671667
/* IPI must map back to the same port# */
16681668
if (data->u.evtchn.deliver.port.port != data->u.evtchn.send_port)
1669-
goto out; /* -EINVAL */
1669+
goto out_noeventfd; /* -EINVAL */
16701670
break;
16711671

16721672
case EVTCHNSTAT_interdomain:
16731673
if (data->u.evtchn.deliver.port.port) {
16741674
if (data->u.evtchn.deliver.port.port >= max_evtchn_port(kvm))
1675-
goto out; /* -EINVAL */
1675+
goto out_noeventfd; /* -EINVAL */
16761676
} else {
16771677
eventfd = eventfd_ctx_fdget(data->u.evtchn.deliver.eventfd.fd);
16781678
if (IS_ERR(eventfd)) {
16791679
ret = PTR_ERR(eventfd);
1680-
goto out;
1680+
goto out_noeventfd;
16811681
}
16821682
}
16831683
break;
@@ -1717,6 +1717,7 @@ static int kvm_xen_eventfd_assign(struct kvm *kvm,
17171717
out:
17181718
if (eventfd)
17191719
eventfd_ctx_put(eventfd);
1720+
out_noeventfd:
17201721
kfree(evtchnfd);
17211722
return ret;
17221723
}

0 commit comments

Comments
 (0)