From patchwork Mon Aug 23 05:56:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken CC X-Patchwork-Id: 62449 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 3B80AB70B8 for ; Mon, 23 Aug 2010 16:53:25 +1000 (EST) Received: from localhost ([127.0.0.1]:45217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnQ99-0004Yn-2B for incoming@patchwork.ozlabs.org; Mon, 23 Aug 2010 02:04:39 -0400 Received: from [140.186.70.92] (port=52903 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnQ4y-0003z3-Aw for qemu-devel@nongnu.org; Mon, 23 Aug 2010 02:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnQ1N-0003B2-Bm for qemu-devel@nongnu.org; Mon, 23 Aug 2010 01:56:38 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:62494) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnQ1N-0003Ay-7b for qemu-devel@nongnu.org; Mon, 23 Aug 2010 01:56:37 -0400 Received: by qwh5 with SMTP id 5so4915564qwh.4 for ; Sun, 22 Aug 2010 22:56:36 -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:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=vGEcx4mcvQHnLrBVEjO2DAIE9fFfHNRTarbD7U+xuhQ=; b=Wl1KlrIhmQnoI2/YqW5ale7Cs21IjDkPS+4Es4CA71Vhj/VD2zoTLftXQYQSfA3mGT a6RJ+FzrIviOQdVVrp1/YCorID8yGtcVU6CkInwGDZllKQMknpWAisJCCkVNdZg9YDK5 dG59pu95wOjdCt2Qd+nBNy2pQUTP82Sme0HYA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=xy9hu9nnsyIKWGVyqpbVZoRMST4imis1/6LK81kv0/H03EIwK16C9RIyIyRUoQTPq9 ZeKK1bNTGRd0jgeOAqvuafUwhcVvc8olMSF65tnxDyNlTtfcSxojJS7GdmPOnqehdCiY g2zzSyszBGbuP+o2WTtBfOVnfSKjvCdUi6tJo= Received: by 10.224.89.11 with SMTP id c11mr2972269qam.344.1282542996779; Sun, 22 Aug 2010 22:56:36 -0700 (PDT) Received: from localhost ([60.247.97.98]) by mx.google.com with ESMTPS id l8sm6662241qck.30.2010.08.22.22.56.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 22 Aug 2010 22:56:35 -0700 (PDT) Date: Mon, 23 Aug 2010 13:56:31 +0800 From: Ken CC To: kvm@vger.kernel.org, mtosatti@redhat.com Message-ID: <20100823053350.2560.472.stgit@k1> References: <20100823053342.2537.19008.stgit@k1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100823053342.2537.19008.stgit@k1> 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 Subject: [Qemu-devel] [PATCH 2/2] pci init: Check if devfn exceeding the max devices 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 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);