From: David Gibson Date: Mon, 28 Nov 2011 20:21:39 +0000 (+0000) Subject: pseries: Fix array overrun bug in PCI code X-Git-Tag: qemu-xen-4.3.0-rc1~18^2~40^2~5 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=57ee5f77c09d365d470cd208c76a7a01a85435b2;p=qemu-upstream-4.4-testing.git 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 Signed-off-by: Alexander Graf (cherry picked from commit 135712de61dfa22368e98914d65b8b0860ec8505) --- 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; }