From: Isaku Yamahata Date: Thu, 9 Sep 2010 02:48:56 +0000 (+0900) Subject: pci: don't ignore invalid parameter for pci_register_bar(). X-Git-Tag: v0.14.0-rc0~500^2^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bbb9c2f7f36d0457cda5f27d7e4422219b3acd8;p=thirdparty%2Fqemu.git pci: don't ignore invalid parameter for pci_register_bar(). Abort when invalid value for region_num is passed to pci_register_bar. That is caller's bug. Abort instead of silently ignoring invalid value. Signed-off-by: Isaku Yamahata Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/pci.c b/hw/pci.c index c28b8a18355..8f48d9b080f 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -765,9 +765,8 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, uint32_t addr; uint64_t wmask; - if ((unsigned int)region_num >= PCI_NUM_REGIONS) - return; - + assert(region_num >= 0); + assert(region_num < PCI_NUM_REGIONS); if (size & (size-1)) { fprintf(stderr, "ERROR: PCI region size must be pow2 " "type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);