xen-pciback: Fix pcistub_device ref leak in pcistub_get_gsi_from_sbdf()

pcistub_get_gsi_from_sbdf() obtains the stub device with
pcistub_device_find(), which returns it with its kref incremented, and
returns psdev->gsi without dropping that reference again.  The caller
cannot release it either, so every lookup leaks one reference to the
stub device.

Release the reference after reading gsi.

Fixes: 2fae6bb7be ("xen/privcmd: Add new syscall to get gsi from dev")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jiqian Chen <Jiqian.Chen@amd.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260916171141.2086627-1-vulab@iscas.ac.cn>
This commit is contained in:
Wentao Liang 2026-09-16 17:11:41 +00:00 committed by Juergen Gross
parent 3b4854b69e
commit cfaf31becd

View File

@ -234,13 +234,16 @@ static int pcistub_get_gsi_from_sbdf(unsigned int sbdf)
int bus = PCI_BUS_NUM(sbdf);
int slot = PCI_SLOT(sbdf);
int func = PCI_FUNC(sbdf);
int gsi;
psdev = pcistub_device_find(domain, bus, slot, func);
if (!psdev)
return -ENODEV;
return psdev->gsi;
gsi = psdev->gsi;
pcistub_device_put(psdev);
return gsi;
}
#endif