From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=57983 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjU2u-0000kV-Ap for qemu-devel@nongnu.org; Thu, 12 Aug 2010 05:25:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjU2t-000230-2c for qemu-devel@nongnu.org; Thu, 12 Aug 2010 05:25:56 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:45466) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjU2s-00022r-UY for qemu-devel@nongnu.org; Thu, 12 Aug 2010 05:25:55 -0400 Received: by pvh11 with SMTP id 11so360575pvh.4 for ; Thu, 12 Aug 2010 02:25:54 -0700 (PDT) Date: Thu, 12 Aug 2010 17:25:50 +0800 From: Ken CC Message-ID: <20100812092550.GB22091@kt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100812091551.32612.14893.stgit@k1> Subject: [Qemu-devel] [PATCH] pci init: Check if devfn exceeding the max devices number supported on bus List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Check before trying subindexing. Signed-off-by: Ken CC --- hw/pci.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index a09fbac..f6f00c6 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -675,6 +675,10 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, error_report("PCI: no slot/function available for %s, all in use", name); return NULL; found: ; + } else if (devfn > PCIBUS_MAX_DEVICES - 1) { + error_report("PCI: devfn is out of bus capacity." + " Only %d devices supported.", PCIBUS_MAX_DEVICES); + return NULL; } else if (bus->devices[devfn]) { error_report("PCI: slot %d function %d not available for %s, in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);