From patchwork Thu Aug 12 10:00: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: 61550 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 C10F9B70A9 for ; Thu, 12 Aug 2010 20:23:14 +1000 (EST) Received: from localhost ([127.0.0.1]:43094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjUwJ-0007O8-20 for incoming@patchwork.ozlabs.org; Thu, 12 Aug 2010 06:23:11 -0400 Received: from [140.186.70.92] (port=42910 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjUqW-0003sw-Oh for qemu-devel@nongnu.org; Thu, 12 Aug 2010 06:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjUaT-0007az-0D for qemu-devel@nongnu.org; Thu, 12 Aug 2010 06:00:37 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:38110) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjUaS-0007as-R0 for qemu-devel@nongnu.org; Thu, 12 Aug 2010 06:00:36 -0400 Received: by pwi2 with SMTP id 2so366599pwi.4 for ; Thu, 12 Aug 2010 03:00:35 -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:subject :message-id:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=ylzdqehVrPFnskt8OIZHnL6Qhul+z+JBsTieRQbfpeg=; b=kBZ9vbrw1svLy+Q7I3Gumw8SnXe5tL5iMlbZFhDHihpBNptDVY++d+1GMk4WUQTQlK YTN+oYFfsS+lozLh4oQzpfdzrNxjQRPf3boKl7MIZtp0Rtd20p1stTJHzkIbbSK7NZnP 90SuD5Hm9U18oXekLZDL9RcFTP4qgoy+4QEQI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:in-reply-to:user-agent; b=jW6PivD+ByzyceNCybr+5VgDbVswq/NbRu706rOR7tvW4A+EP5VcwoEH7/iYsaxDJG jlJM+9LzdNTPIMjBX/2VcYXqH1DFFkz/xQIr9Ljg9Yi29sx93zWE1oI9F8qvWpogjUWQ TaP2gbaO4+TywlYHmwakZO4ingoirQvp0p2Xw= Received: by 10.142.203.5 with SMTP id a5mr15630323wfg.154.1281607235629; Thu, 12 Aug 2010 03:00:35 -0700 (PDT) Received: from localhost ([60.247.97.98]) by mx.google.com with ESMTPS id z1sm1342201wfd.15.2010.08.12.03.00.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 12 Aug 2010 03:00:35 -0700 (PDT) Date: Thu, 12 Aug 2010 18:00:31 +0800 From: Ken CC To: qemu-devel@nongnu.org Message-ID: <20100812100031.GC22091@kt> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100812092533.GA22091@kt> User-Agent: StGit/0.15-97-g9680 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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);