]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Avoid unaligned accesses to extended capabilities.
authorMartin Mares <mj@ucw.cz>
Sat, 16 Jan 2010 11:10:09 +0000 (12:10 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 16 Jan 2010 11:10:09 +0000 (12:10 +0100)
The PCIe spec tells that all capabilities must be DWORD aligned and the bottom
2 bits of all capability pointers are reserved for future use and must be
ignored when read.

Should fix Mandriva bug #56772.

lib/caps.c
ls-ecaps.c

index 19e04d5f2d355d2f04d5f05b014a4c385d32c9c0..ff4d9c43c97f306a394d9f26ac7ed8b1c18322e4 100644 (file)
@@ -71,7 +71,7 @@ pci_scan_ext_caps(struct pci_dev *d)
       if (been_there[where]++)
        break;
       pci_add_cap(d, where, id, PCI_CAP_EXTENDED);
-      where = header >> 20;
+      where = (header >> 20) & ~3;
     }
   while (where);
 }
index 0d14b7f1c37d9671bbfabcfd5fac9e8e945234c8..7888214d5c9db42a65fc95f5c0c04f193e9cf733 100644 (file)
@@ -284,6 +284,6 @@ show_ext_caps(struct device *d)
            printf("#%02x\n", id);
            break;
        }
-      where = header >> 20;
+      where = (header >> 20) & ~3;
     } while (where);
 }