Opened on 06/29/17 at 00:23:20
Last modified on 06/29/17 at 16:18:00
#3055 assigned defect
Infinite Loop in PCI Library Auto Bus Enumeration
Reported by: | Jeffrey Hill | Owned by: | Daniel Hellstrom |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | score | Version: | 4.11 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
There are some infinite loops in the PCI Library Auto Bus Enumeration, fixed as follows. Also, there is a memory leak at where the pragma indicates.
@@ -76,6 +76,7 @@ static void pci_res_insert(struct pci_res **root, struct pci_res *res) * sorted after resulting boundary - the boundary after * the resource. */ + if ( size ) { while (curr && (curr->boundary >= boundary)) { if (curr->boundary == boundary) { /* Find Resulting boundary of size */ @@ -97,6 +98,7 @@ static void pci_res_insert(struct pci_res **root, struct pci_res *res) last = curr; curr = curr->next; } + } if (last == NULL) { /* Insert first in list */ @@ -106,6 +108,7 @@ static void pci_res_insert(struct pci_res **root, struct pci_res *res) last->next = res; res->next = curr; } + } #ifdef DEBUG @@ -114,9 +117,9 @@ void pci_res_list_print(struct pci_res *root) if (root == NULL) return; - printf("RESOURCE LIST:\n"); + DBG("RESOURCE LIST:\n"); while (root) { - printf(" SIZE: 0x%08x, BOUNDARY: 0x%08x\n", root->size, + DBG(" SIZE: 0x%08x, BOUNDARY: 0x%08x\n", root->size, root->boundary); root = root->next; } @@ -182,13 +185,13 @@ static void pci_res_reorder(struct pci_res *root) * and next */ hole_size = start_next - start; + /* Detect dead hole */ + if (hole_size > 0) { /* Find Boundary of START */ hole_boundary = 1; while ((start & hole_boundary) == 0) hole_boundary = hole_boundary<<1; - /* Detect dead hole */ - if (hole_size > 0) { /* Step through list and try to find a resource that * can fit into hole. Take into account hole start * boundary and hole size. @@ -509,6 +512,7 @@ static void pci_add_res_bus(struct pci_bus *bus, int type) { int tindex = type - 1; +#pragma message ("memory leak likely, second pass through here") /* Clear old resources */ bus->busres[tindex] = NULL; @@ -580,7 +584,7 @@ static int pci_add_res_dev(struct pci_dev *dev, void *arg) } } - /* Normal PCI Device as max 6 BARs and a ROM Bar. + /* Normal PCI Device has max 6 BARs and a ROM Bar. * Insert BARs into the sorted resource list. */ for (i = 0; i < DEV_RES_CNT; i++) { @@ -621,7 +625,7 @@ static uint32_t pci_alloc_res(struct pci_bus *bus, int type, if ((starttmp + res->size - 1) > end) { /* Not enough memory available for this resource */ - printk("PCI[%x:%x:%x]: DEV BAR%d (%d): no resource " + DBG("PCI[%x:%x:%x]: DEV BAR%d (%d): no resource " "assigned\n", PCI_DEV_EXPAND(dev->busdevfun), res->bar, res->flags & PCI_RES_TYPE_MASK); @@ -725,7 +729,7 @@ static void pci_set_bar(struct pci_dev *dev, int residx) tmp = ((res->end-1) & 0xffff0000) | (res->start >> 16); DBG("PCI[%x:%x:%x]: BRIDGE BAR 0x%x: 0x%08x [0x30: 0x%x]\n", - PCI_DEV_EXPAND(pcidev), 0x1C, tmp, tmp2); + PCI_DEV_EXPAND(pcidev), 0x1C, tmp, tmp16); PCI_CFG_W16(pcidev, 0x1C, tmp16); PCI_CFG_W32(pcidev, 0x30, tmp); } else if (is_bridge && (res->bar >= BRIDGE_RES_MEMIO)) {
Change History (3)
comment:1 Changed on 06/29/17 at 16:15:15 by Jeffrey Hill
comment:2 Changed on 06/29/17 at 16:16:00 by Jeffrey Hill
comment:3 Changed on 06/29/17 at 16:17:58 by Joel Sherrill
Owner: | changed from joel.sherrill@… to Daniel Hellstrom |
---|---|
Status: | new → assigned |
Daniel Hellstrom wrote this code and should review this ticket.
Note: See
TracTickets for help on using
tickets.
trace