From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken CC Subject: [PATCH 2/4] pci init: fail qemu if devfn exceeding the max function number supported on bus Date: Tue, 24 Aug 2010 21:27:10 +0800 Message-ID: <20100824132710.GB19469@kt> References: <20100824132525.GA19469@kt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: qemu-devel@nongnu.org, mst@redhat.com To: yamahata@valinux.co.jp, avi@redhat.com, kvm@vger.kernel.org Return-path: Received: from mail-qw0-f46.google.com ([209.85.216.46]:52376 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755152Ab0HXN1O (ORCPT ); Tue, 24 Aug 2010 09:27:14 -0400 Received: by qwh6 with SMTP id 6so6077129qwh.19 for ; Tue, 24 Aug 2010 06:27:14 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20100824132525.GA19469@kt> Sender: kvm-owner@vger.kernel.org List-ID: Check if devfn < PCIBUS_MAX_DEVICES * PCI_FUNCTIONS_PER_DEVICE Signed-off-by: Ken CC --- hw/pci.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 9234fe3..fc4becd 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -747,6 +747,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, PCIConfigWriteFunc *config_write, bool is_bridge) { + assert(devfn / PCI_FUNCTIONS_PER_DEVICE < PCIBUS_MAX_DEVICES); if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) {