All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Engraf <david.engraf@sysgo.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Wei Yang <weiyang@linux.vnet.ibm.com>,
	linux-pci@vger.kernel.org
Subject: [PATCH] PCI: Fix __pci_bus_size_bridges when bridge is not available
Date: Thu, 12 May 2016 08:56:58 +0200	[thread overview]
Message-ID: <5734293A.6040702@sysgo.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

A virtual PCI controller may not have a bridge device, thus when 
__pci_bus_size_bridges is called, it will generate a NULL pointer 
exception when accessing bus->self->class. The attached patch adds a 
check to verify if a bridge has been set. Without a bridge device, the 
function returns.

Signed-off-by: David Engraf <david.engraf <at> sysgo.com>


[-- Attachment #2: setup-pci.patch --]
[-- Type: text/x-diff, Size: 465 bytes --]

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 55641a3..ddb3381 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1245,6 +1245,10 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 	if (pci_is_root_bus(bus))
 		return;
 
+	/* bridge device available? */
+	if (!bus->self)
+		return;
+
 	switch (bus->self->class >> 8) {
 	case PCI_CLASS_BRIDGE_CARDBUS:
 		/* don't size cardbuses yet. */

             reply	other threads:[~2016-05-12  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12  6:56 David Engraf [this message]
2016-06-13 20:28 ` [PATCH] PCI: Fix __pci_bus_size_bridges when bridge is not available Bjorn Helgaas

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=5734293A.6040702@sysgo.com \
    --to=david.engraf@sysgo.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=weiyang@linux.vnet.ibm.com \
    /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.