[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] pci: fix handling of PCI bridges with subordinate bus number 0xff
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
- Date: Fri, 24 Sep 2021 10:10:12 +0100
- Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
- Cc: <jbeulich@xxxxxxxx>, <paul@xxxxxxx>, Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
- Delivery-date: Fri, 24 Sep 2021 09:10:37 +0000
- Ironport-data: A9a23:JCPae6nWl2dbiEd8f9ZNu63o5gxPIURdPkR7XQ2eYbSJt1+Wr1Gzt xIeCz+AaaqJYWT2KNgja4Sy9kkBuJSAn4VlTwRpq3hhEyMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA185IMsdoUg7wbdh09Q02YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 NpGi4PzZDgUBIOPhN0hAxkHFA9vZoQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBMjkO5lZtmt93zHYC/cgaZvCX7/L9ZlT2zJYasVmQKuFP JVJOWoHgBLoPCUWC28QT68Fk/6ZgUmlcDZg933Oqv9ii4TU5FMoi+W8WDbPQfSSTNhRtlaVo CTB5WuRKhMQOcGbyDGF2mmxneKJliT+MKoCGbv9+vN0jVm7wm0IFAZQRVa9ueO+iEO1R5RYM UN8x8Y1hfFsrgrxFIC7BkDm5i7f1vIBZzZOO+Ix1h7O55Xp2SjaGlE4Hj4eb/I37+ZjEFTGy WS1t9/uADVutpicRnSc6q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wh9T1JDi2Q5VYNzzFNWKUClKfHHfuVp5jRyXBlU JOQUTuz92tpFOzM1AzVYzHw/V0Db8i3PxcX1JH76BBDX0vEDOu4xkMAh3+TBB7ARP0mxHPzvEv /vumyUYgY/QE2qoX+AM4bU1l0Xsyhbf0ezfITnoM2R0qmXDJJi23pzTUpxTJARbZEultUDfjyN PZ96OhZAsU10WQ8zE03YRDn5WP3HD0D1yt1jGXgjIKTQQsKHv3PBaYZnvedICZr3n6m3LnM2O7 ajXEShY85AnNTT3WdO2DGpJx
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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 <igor.druzhinin@xxxxxxxxxx>
---
v2:
- fix free_pdev() as well
- style fixes
---
xen/drivers/passthrough/pci.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index fc4fa2e..d65cda8 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -363,8 +363,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:
@@ -431,7 +430,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:
--
2.7.4
|