From: Igor Druzhinin Date: Fri, 15 Oct 2021 09:18:19 +0000 (+0200) Subject: pci: fix handling of PCI bridges with subordinate bus number 0xff X-Git-Tag: archive/raspbian/4.14.3+32-g9de3671772-1_deb11u1+rpi1^2^2~48^2~20 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=28a28fa8194107794d5b8bd08cad5a46a67f6d64;p=xen.git pci: fix handling of PCI bridges with subordinate bus number 0xff Bus number 0xff is valid according to the PCI spec. Using u8 typed sub_bus and assigning 0xff to it will result in the following loop getting stuck. for ( ; sec_bus <= sub_bus; sec_bus++ ) {...} Just change its type to unsigned int similarly to what is already done in dmar_scope_add_buses(). Signed-off-by: Igor Druzhinin Reviewed-by: Jan Beulich Reviewed-by: Bertrand Marquis master commit: 9c3b9800e2019c93ab22da69e4a0b22d6fb059ec master date: 2021-09-28 16:04:50 +0200 --- diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 981e63061d..f15af59764 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -375,8 +375,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn) /* update bus2bridge */ switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) ) { - u16 cap; - u8 sec_bus, sub_bus; + unsigned int cap, sec_bus, sub_bus; case DEV_TYPE_PCIe2PCI_BRIDGE: case DEV_TYPE_LEGACY_PCI_BRIDGE: @@ -443,7 +442,7 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev) /* update bus2bridge */ switch ( pdev->type ) { - uint8_t sec_bus, sub_bus; + unsigned int sec_bus, sub_bus; case DEV_TYPE_PCIe2PCI_BRIDGE: case DEV_TYPE_LEGACY_PCI_BRIDGE: