Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 62cc5fc7b2e0 ("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>

authored by

Jason Andryuk and committed by
Juergen Gross
08df2d7d 29c2f18d

+4 -3
+4 -3
drivers/xen/events/events_base.c
··· 1318 1318 { 1319 1319 struct evtchn_status status; 1320 1320 evtchn_port_t port; 1321 - int rc = -ENOENT; 1322 1321 1323 1322 memset(&status, 0, sizeof(status)); 1324 1323 for (port = 0; port < xen_evtchn_max_channels(); port++) { 1324 + int rc; 1325 + 1325 1326 status.dom = DOMID_SELF; 1326 1327 status.port = port; 1327 1328 rc = HYPERVISOR_event_channel_op(EVTCHNOP_status, &status); ··· 1332 1331 continue; 1333 1332 if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) { 1334 1333 *evtchn = port; 1335 - break; 1334 + return 0; 1336 1335 } 1337 1336 } 1338 - return rc; 1337 + return -ENOENT; 1339 1338 } 1340 1339 1341 1340 /**