From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken CC Subject: [PATCH] pci init: Check if devfn exceeding the max devices number supported on bus Date: Mon, 23 Aug 2010 13:53:14 +0800 Message-ID: <376108071.2560.472.stgit@k1> References: <20100823053342.2537.19008.stgit@k1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: qemu-devel@nongnu.org To: kvm@vger.kernel.org, mtosatti@redhat.com Return-path: Received: from mail-qy0-f174.google.com ([209.85.216.174]:65415 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508Ab0HWFxU (ORCPT ); Mon, 23 Aug 2010 01:53:20 -0400 Received: by qyk9 with SMTP id 9so2374381qyk.19 for ; Sun, 22 Aug 2010 22:53:20 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20100823053342.2537.19008.stgit@k1> Sender: kvm-owner@vger.kernel.org List-ID: 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);