All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ken CC <ken.ccao@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] pci init: Check if devfn exceeding the max devices number supported on bus
Date: Thu, 12 Aug 2010 18:00:31 +0800	[thread overview]
Message-ID: <20100812100031.GC22091@kt> (raw)
In-Reply-To: <20100812092533.GA22091@kt>

Check before trying subindexing.

Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
 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);

  reply	other threads:[~2010-08-12 10:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12  9:25 [Qemu-devel] [PATCH] PCI: define max devices number on PCIBus as PCIBus_MAX_DEVICES in pci.h Ken CC
2010-08-12 10:00 ` Ken CC [this message]
2010-08-23  5:46 [PATCH 1/2] " Ken CC
2010-08-23  5:56 ` [Qemu-devel] [PATCH 2/2] pci init: Check if devfn exceeding the max devices number supported on bus Ken CC
2010-08-23  9:56   ` Isaku Yamahata
2010-08-23  9:56     ` Isaku Yamahata
2010-08-24  1:43     ` Ken CC
2010-08-24  1:43       ` Ken CC
2010-08-24  2:18       ` Isaku Yamahata
2010-08-24  2:18         ` Isaku Yamahata

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100812100031.GC22091@kt \
    --to=ken.ccao@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.