aboutsummaryrefslogtreecommitdiffstats
path: root/hw/spapr_pci.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2011-11-29 07:21:39 +0100
committerAndrzej Zaborowski <balrog@zabor.org>2011-12-05 21:38:50 +0100
commit81584fd50deb3c324cafc854a946dbb6b83c2fc6 (patch)
treed6c2cfce3b58c8c151d730c8aa299c0738d0f391 /hw/spapr_pci.c
parentf4fc247b0df2dfccae80618ccf6741a9b9e50e49 (diff)
pseries: Fix array overrun bug in PCI code
spapr_populate_pci_devices() containd a loop with PCI_NUM_REGIONS (7) iterations. However this overruns the 'bars' global array, which only has 6 elements. In fact we only want to run this loop for things listed in the bars array, so this patch corrects the loop bounds to reflect that. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
Diffstat (limited to 'hw/spapr_pci.c')
-rw-r--r--hw/spapr_pci.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c
index 716258854..9b6a032cc 100644
--- a/hw/spapr_pci.c
+++ b/hw/spapr_pci.c
@@ -454,7 +454,7 @@ int spapr_populate_pci_devices(sPAPRPHBState *phb,
reg[0].size = 0;
n = 0;
- for (i = 0; i < PCI_NUM_REGIONS; ++i) {
+ for (i = 0; i < ARRAY_SIZE(bars); ++i) {
if (0 == dev->io_regions[i].size) {
continue;
}