Skip to contentSkip to conversation

pcie: Fix bug in pcie_ext_cap_set_next

PATCH Applied Knut Omang 2 participants 2 messages Dec 18, 2012 – Dec 25, 2012

lore
Share & tools
lore

Knut Omang

author
#0 lore raw

PATCH 1/1 pcie: Fix bug in pcie_ext_cap_set_next

Upper 16 bits of the PCIe Extended Capability Header was truncated during update, also breaking pcie_add_capability.

---
 hw/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pcie.c +1 -1
index 7c92f19..fa260af 100644
@@ -494,7 +494,7 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
 
 static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
 {
-    uint16_t header = pci_get_long(dev->config + pos);
+    uint32_t header = pci_get_long(dev->config + pos);
     assert(!(next & (PCI_EXT_CAP_ALIGN - 1)));
     header = (header & ~PCI_EXT_CAP_NEXT_MASK) |
         ((next << PCI_EXT_CAP_NEXT_SHIFT) & PCI_EXT_CAP_NEXT_MASK);
Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 4 lines · Knut Omang

Upper 16 bits of the PCIe Extended Capability Header was truncated during update, also breaking pcie_add_capability.

Applied, thanks.

Quoted 20 lines
---
 hw/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pcie.c +1 -1
index 7c92f19..fa260af 100644
@@ -494,7 +494,7 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
 
 static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
 {
-    uint16_t header = pci_get_long(dev->config + pos);
+    uint32_t header = pci_get_long(dev->config + pos);
     assert(!(next & (PCI_EXT_CAP_ALIGN - 1)));
     header = (header & ~PCI_EXT_CAP_NEXT_MASK) |
         ((next << PCI_EXT_CAP_NEXT_SHIFT) & PCI_EXT_CAP_NEXT_MASK);
Signature · 1 line
1.7.11.7