Skip to content

Commit 08df2d7

Browse files
jandryukjgross1
authored andcommitted
xen/events: Cleanup find_virq() return codes
rc is overwritten by the evtchn_status hypercall in each iteration, so the return value will be whatever the last iteration is. This could incorrectly return success even if the event channel was not found. Change to an explicit -ENOENT for an un-found virq and return 0 on a successful match. Fixes: 62cc5fc ("xen/pv-on-hvm kexec: rebind virqs to existing eventchannel ports") Cc: stable@vger.kernel.org Signed-off-by: Jason Andryuk <jason.andryuk@amd.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Juergen Gross <jgross@suse.com> Message-ID: <20250828003604.8949-2-jason.andryuk@amd.com>
1 parent 29c2f18 commit 08df2d7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/xen/events/events_base.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,10 +1318,11 @@ static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn)
13181318
{
13191319
struct evtchn_status status;
13201320
evtchn_port_t port;
1321-
int rc = -ENOENT;
13221321

13231322
memset(&status, 0, sizeof(status));
13241323
for (port = 0; port < xen_evtchn_max_channels(); port++) {
1324+
int rc;
1325+
13251326
status.dom = DOMID_SELF;
13261327
status.port = port;
13271328
rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status);
@@ -1331,10 +1332,10 @@ static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t *evtchn)
13311332
continue;
13321333
if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) {
13331334
*evtchn = port;
1334-
break;
1335+
return 0;
13351336
}
13361337
}
1337-
return rc;
1338+
return -ENOENT;
13381339
}
13391340

13401341
/**

0 commit comments

Comments
 (0)