From patchwork Mon Aug 23 05:53:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken CC X-Patchwork-Id: 123341 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7N5rYYB029549 for ; Mon, 23 Aug 2010 05:53:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753178Ab0HWFxV (ORCPT ); Mon, 23 Aug 2010 01:53:21 -0400 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) 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=ylzdqehVrPFnskt8OIZHnL6Qhul+z+JBsTieRQbfpeg=; b=jcLDr0ME2hz9GLYBkhVMPF8FLC4NYUxo7aq9nNMQOHVX62M94dKJBCSzUWYcL7FxxE Cju6EkVvAU7ProGUc0uAB29qzKa8lEotDLuthlFgM7ahJeBbXnMm2/5aot7fRr/RKYxs rY9lJ+HKnD3dxT2hFCS+S9J3hJ9e01pT53ax0= 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=CYMYwoeFaRK2kVYv4DFDXdolb64UdbXL0xBiKzNrffE4nZofzml5sPKCJ1MBLZrGTm 9XT4mW68pu31KpwPUlyBuRW5jLdyay3GSIvz5pNtyR8YTc5w3YCKr0Juh4wJxJJs1goJ oUrrDUWMnuZ9xvAnQ9jImQ2fA+e1Saoyjvjyg= Received: by 10.229.226.78 with SMTP id iv14mr3209742qcb.159.1282542799866; Sun, 22 Aug 2010 22:53:19 -0700 (PDT) Received: from localhost ([60.247.97.98]) by mx.google.com with ESMTPS id l13sm6473917qck.7.2010.08.22.22.53.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 22 Aug 2010 22:53:19 -0700 (PDT) Date: Mon, 23 Aug 2010 13:53:14 +0800 From: Ken CC To: kvm@vger.kernel.org, mtosatti@redhat.com Cc: qemu-devel@nongnu.org Subject: [PATCH] pci init: Check if devfn exceeding the max devices number supported on bus Message-ID: <376108071.2560.472.stgit@k1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100823053342.2537.19008.stgit@k1> User-Agent: StGit/0.15-97-g9680 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 23 Aug 2010 05:53:34 +0000 (UTC) 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);