mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Chiang <achiang@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Troy Moure <twmoure@szypr.net>,
	linux-acpi@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] ACPI: update acpi_get_pci_dev() comments
Date: Fri, 26 Jun 2009 15:16:26 -0600	[thread overview]
Message-ID: <20090626211626.GB980@ldl.fc.hp.com> (raw)

Recent commit 412af978 (ACPI: video: prevent NULL deref in
acpi_get_pci_dev()) was added to prevent a boot oops.

Update the implementation with some notes and analysis as to why
the fix is correct.

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Troy Moure <twmoure@szypr.net>
Signed-off-by: Alex Chiang <achiang@hp.com>
---
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 55b5b90..570f32e 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -344,6 +344,16 @@ struct acpi_handle_node {
  * function returns a pointer to its data structure.  The caller must
  * decrement the reference count by calling pci_dev_put().
  * If no device is found, %NULL is returned.
+ *
+ * XXX: You may be surprised at the results if you call this interface
+ * with a handle to a PCI root bridge and expect to get a pci_dev back.
+ * The PCI specification does not require a PCI root bridge to present
+ * configuration space, and thus may not have a valid associated pci_dev.
+ *
+ * [nb, all P2P bridges _are_ required to present configuration space]
+ *
+ * A PCI root bridge that presents config space is referred to as
+ * "materialized"; its converse is "non-materialized".
  */
 struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
 {
@@ -385,6 +395,11 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
 	 * Now, walk back down the PCI device tree until we return to our
 	 * original handle. Assumes that everything between the PCI root
 	 * bridge and the device we're looking for must be a P2P bridge.
+	 *
+	 * Note! It's possible for ACPI to describe a non-existent PCI device
+	 * due to either hotplug or a namespace shared across different
+	 * platforms with just enable or present bits to mask them out from
+	 * the initial PCI scan. So take care to check for a NULL pdev.
 	 */
 	list_for_each_entry(node, &device_list, node) {
 		acpi_handle hnd = node->handle;

                 reply	other threads:[~2009-06-26 21:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090626211626.GB980@ldl.fc.hp.com \
    --to=achiang@hp.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=twmoure@szypr.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®