From patchwork Tue Aug 24 13:27:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken CC X-Patchwork-Id: 62572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 39E74B70CC for ; Tue, 24 Aug 2010 23:30:36 +1000 (EST) Received: from localhost ([127.0.0.1]:37309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OntaD-0000aK-5r for incoming@patchwork.ozlabs.org; Tue, 24 Aug 2010 09:30:33 -0400 Received: from [140.186.70.92] (port=52482 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OntX1-0006wR-NB for qemu-devel@nongnu.org; Tue, 24 Aug 2010 09:27:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OntX0-0000jY-II for qemu-devel@nongnu.org; Tue, 24 Aug 2010 09:27:15 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:36004) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OntX0-0000jU-Ex for qemu-devel@nongnu.org; Tue, 24 Aug 2010 09:27:14 -0400 Received: by qyk31 with SMTP id 31so5568355qyk.4 for ; Tue, 24 Aug 2010 06:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=XOK/nq8un01x3vQe/EwIlfqyim99UPo3mD3Nq/9JwXo=; b=IiPdFPecg3quxfqqNeKVSl25FG/O+4X5InkJ0Tc+q4SEfN+wZ1lQtq8IK6YHyfe7Sj /KBkD4Xv1n9GbaH5Z7IaOBmu1sqtxeeclDK/ccnSEb6XmevRDxuhRUIkD/nrch8TOIGG rPlHbsSJ2K+Ii8y/udY11UBrugmng8ioaFP2Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:in-reply-to:user-agent; b=pRMc5jMKTUtHUcNFkKJuB+iktlxXCvYvF6yVr8htGCkLCPdmHpFdyyEyRJRX65pOJ+ ISuzuFN3bEsuPEhIYU27PPVJrJBowKrT6gGIwMV0TArGMNC1mKLilRNhtCkVNhST/v/Q uvHUPc9VT1kR3snMrvcuOPgZKOiAIgVhkRqlo= Received: by 10.224.61.12 with SMTP id r12mr4458399qah.101.1282656433917; Tue, 24 Aug 2010 06:27:13 -0700 (PDT) Received: from localhost ([60.247.97.98]) by mx.google.com with ESMTPS id f15sm101905qcr.1.2010.08.24.06.27.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 24 Aug 2010 06:27:13 -0700 (PDT) Date: Tue, 24 Aug 2010 21:27:10 +0800 From: Ken CC To: yamahata@valinux.co.jp, avi@redhat.com, kvm@vger.kernel.org Message-ID: <20100824132710.GB19469@kt> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100824132525.GA19469@kt> User-Agent: StGit/0.15-97-g9680 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-devel@nongnu.org, mst@redhat.com Subject: [Qemu-devel] [PATCH 2/4] pci init: fail qemu if devfn exceeding the max function number supported on bus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) {