public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alex Chiang <achiang@hp.com>
Cc: Xiaotian Feng <dfeng@redhat.com>,
	lenb@kernel.org, bjorn.helgaas@hp.com, andrew.patterson@hp.com,
	jbarnes@virtuousgeek.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] acpi: pci_root: fix NULL pointer deref after resume from suspend
Date: Mon, 28 Sep 2009 22:43:44 +0200	[thread overview]
Message-ID: <200909282243.44226.rjw@sisk.pl> (raw)
In-Reply-To: <20090928173819.GA2441@ldl.fc.hp.com>

On Monday 28 September 2009, Alex Chiang wrote:
> Hi Xiaotian,
> 
> Thanks for the bug report.
> 
> * Xiaotian Feng <dfeng@redhat.com>:
> > commit 275582 introduces acpi_get_pci_dev(), but pdev->subordinate
> > can be NULL, then a NULL was passed to pci_get_slot, this results
> > the kernel oops when resume from suspend.
> > 
> > This patch resolves following kernel oops:
> > BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
> > IP: [<ffffffff812217e7>] pci_get_slot+0x4c/0x8c
> > 
> > Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
> > ---
> >  drivers/acpi/pci_root.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> > index 3112221..3c35144 100644
> > --- a/drivers/acpi/pci_root.c
> > +++ b/drivers/acpi/pci_root.c
> > @@ -387,7 +387,11 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
> >  		if (!pdev || hnd == handle)
> >  			break;
> >  
> > -		pbus = pdev->subordinate;
> > +		if (pdev->subordinate)
> > +			pbus = pdev->subordinate;
> > +		else
> > +			pbus = pdev->bus;
> > +
> 
> I'm a little confused by this. If we start from the PCI root
> bridge and walk back down the hierarchy, shouldn't everything
> between the root and the device be a P2P bridge?

Well, if my reading of the code is correct, there's no guarantee that
pci_get_slot() will always return either the right device or a bridge.  If it
returns anything that's not a bridge or the device we're looking for, we'll hit
the NULL pointer deref.

In fact it looks like we should also clear pdev if no device was found.

Thanks,
Rafael

  reply	other threads:[~2009-09-28 20:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-28  6:31 [PATCH] acpi: pci_root: fix NULL pointer deref after resume from suspend Xiaotian Feng
2009-09-28 17:38 ` Alex Chiang
2009-09-28 20:43   ` Rafael J. Wysocki [this message]
2009-09-28 21:05     ` Rafael J. Wysocki
2009-09-28 22:20       ` Alex Chiang
2009-09-28 22:50         ` Rafael J. Wysocki
2009-09-29 10:11           ` Danny Feng
2009-09-29 20:08             ` Rafael J. Wysocki
2009-09-29 20:49               ` Alex Chiang
2009-09-29 23:31                 ` Rafael J. Wysocki
2009-09-29  1:44   ` Danny Feng
2009-09-29 20:12     ` Rafael J. Wysocki
2009-09-30  2:46       ` Danny Feng
2009-09-30 21:26         ` Rafael J. Wysocki
2009-10-01 20:05     ` Alex Chiang
2009-10-03 22:56       ` Rafael J. Wysocki
2009-10-09  1:17         ` Danny Feng
2009-10-09  2:26         ` Danny Feng
2009-10-09 21:46           ` Rafael J. Wysocki
2009-10-12  3:05             ` Danny Feng
2009-10-09  1:16       ` Danny Feng
2009-10-09  2:28       ` Danny Feng

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=200909282243.44226.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=achiang@hp.com \
    --cc=andrew.patterson@hp.com \
    --cc=bjorn.helgaas@hp.com \
    --cc=dfeng@redhat.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox