From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60648 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ot1vF-0002B3-1Y for qemu-devel@nongnu.org; Tue, 07 Sep 2010 13:25:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ot1vB-0004pY-FD for qemu-devel@nongnu.org; Tue, 07 Sep 2010 13:25:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10490) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ot1vB-0004pM-7q for qemu-devel@nongnu.org; Tue, 07 Sep 2010 13:25:25 -0400 Date: Tue, 7 Sep 2010 20:19:24 +0300 From: "Michael S. Tsirkin" Message-ID: <20100907171924.GC18374@redhat.com> References: <20100824132525.GA19469@kt> <20100824132710.GB19469@kt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100824132710.GB19469@kt> Subject: [Qemu-devel] Re: [PATCH 2/4] pci init: fail qemu if devfn exceeding the max function number supported on bus List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ken CC Cc: yamahata@valinux.co.jp, avi@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org On Tue, Aug 24, 2010 at 09:27:10PM +0800, Ken CC wrote: > 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); I guess it'll happen to work even for < 0, but it might be obvious to only do this in >= 0 case. Just remove the 'else' and stick the assert there. > if (devfn < 0) { > for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); > devfn += PCI_FUNC_MAX) {