From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Joonsoo Kim <js1304@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] Driver core: treat unregistered bus_types as having no devices
Date: Wed, 30 Jan 2013 09:09:21 +0100 [thread overview]
Message-ID: <20130130080921.GA15263@kroah.com> (raw)
In-Reply-To: <CAErSpo6B+TWKpP=P6hoNLzziq9Po-OwW2zGBHCc+qSJ2HtTYNQ@mail.gmail.com>
On Tue, Jan 29, 2013 at 04:47:13PM -0700, Bjorn Helgaas wrote:
> On Tue, Jan 29, 2013 at 4:44 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > A bus_type has a list of devices (klist_devices), but the list and the
> > subsys_private structure that contains it are not initialized until the
> > bus_type is registered with bus_register().
> >
> > The panic/reboot path has fixups that look up devices in pci_bus_type. If
> > we panic before registering pci_bus_type, the bus_type exists but the list
> > does not, so mach_reboot_fixups() trips over a null pointer and panics
> > again:
> >
> > mach_reboot_fixups
> > pci_get_device
> > ..
> > bus_find_device(&pci_bus_type, ...)
> > bus->p is NULL
> >
> > Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> > ---
> > drivers/base/bus.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> > index 24eb078..6856303 100644
> > --- a/drivers/base/bus.c
> > +++ b/drivers/base/bus.c
> > @@ -290,7 +290,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
> > struct device *dev;
> > int error = 0;
> >
> > - if (!bus)
> > + if (!bus || !bus->p)
> > return -EINVAL;
> >
> > klist_iter_init_node(&bus->p->klist_devices, &i,
> > @@ -324,7 +324,7 @@ struct device *bus_find_device(struct bus_type *bus,
> > struct klist_iter i;
> > struct device *dev;
> >
> > - if (!bus)
> > + if (!bus || !bus->p)
> > return NULL;
> >
> > klist_iter_init_node(&bus->p->klist_devices, &i,
> >
>
> Sorry, I meant to include this in the original post:
>
> Joonsoo reported a problem when panicking before PCI was initialized.
> I think this patch should be sufficient to replace the patch he posted
> here: https://lkml.org/lkml/2012/12/28/75 ("[PATCH] x86, reboot: skip
> reboot_fixups in early boot phase")
Don't you think that should be applied as well? That makes things a bit
more explicit in the boot process as to exactly what is going on. The
driver core changes is good to have if other people mess things up like
this in the future, don't rely on it to protect you from foolish things.
thanks,
greg k-h
next prev parent reply other threads:[~2013-01-30 8:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-29 23:44 [PATCH] Driver core: treat unregistered bus_types as having no devices Bjorn Helgaas
2013-01-29 23:47 ` Bjorn Helgaas
2013-01-30 8:09 ` Greg Kroah-Hartman [this message]
2013-01-30 17:21 ` 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=20130130080921.GA15263@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bhelgaas@google.com \
--cc=hpa@zytor.com \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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