linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci/of: Don't crash when bridge parent is NULL.
@ 2011-08-16 18:24 David Daney
  2011-08-16 19:16 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2011-08-16 18:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Daney, Benjamin Herrenschmidt, Jesse Barnes, linux-pci,
	Grant Likely

In pcibios_get_phb_of_node(), we will crash while booting if
bus->bridge->parent is NULL.

Check for this case and avoid dereferencing the NULL pointer.

Signed-off-by: David Daney <david.daney@cavium.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: linux-pci@vger.kernel.org
Cc: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/pci/of.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index c94d37e..f092993 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -55,7 +55,7 @@ struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus)
 	 */
 	if (bus->bridge->of_node)
 		return of_node_get(bus->bridge->of_node);
-	if (bus->bridge->parent->of_node)
+	if (bus->bridge->parent && bus->bridge->parent->of_node)
 		return of_node_get(bus->bridge->parent->of_node);
 	return NULL;
 }
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] pci/of: Don't crash when bridge parent is NULL.
  2011-08-16 18:24 [PATCH] pci/of: Don't crash when bridge parent is NULL David Daney
@ 2011-08-16 19:16 ` Benjamin Herrenschmidt
  2011-08-17  4:11   ` Jesse Barnes
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2011-08-16 19:16 UTC (permalink / raw)
  To: David Daney; +Cc: linux-kernel, Jesse Barnes, linux-pci, Grant Likely

On Tue, 2011-08-16 at 11:24 -0700, David Daney wrote:
> In pcibios_get_phb_of_node(), we will crash while booting if
> bus->bridge->parent is NULL.
> 
> Check for this case and avoid dereferencing the NULL pointer.
> 
> Signed-off-by: David Daney <david.daney@cavium.com>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Jesse or Grant, I'm travelling, can any of you send that to Linus asap ?

Cheers,
Ben.

> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: linux-pci@vger.kernel.org
> Cc: Grant Likely <grant.likely@secretlab.ca>
> ---
>  drivers/pci/of.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index c94d37e..f092993 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -55,7 +55,7 @@ struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus)
>  	 */
>  	if (bus->bridge->of_node)
>  		return of_node_get(bus->bridge->of_node);
> -	if (bus->bridge->parent->of_node)
> +	if (bus->bridge->parent && bus->bridge->parent->of_node)
>  		return of_node_get(bus->bridge->parent->of_node);
>  	return NULL;
>  }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pci/of: Don't crash when bridge parent is NULL.
  2011-08-16 19:16 ` Benjamin Herrenschmidt
@ 2011-08-17  4:11   ` Jesse Barnes
  2011-08-17 11:29     ` Grant Likely
  0 siblings, 1 reply; 4+ messages in thread
From: Jesse Barnes @ 2011-08-17  4:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: David Daney, linux-kernel, linux-pci, Grant Likely

On Tue, 16 Aug 2011 14:16:18 -0500
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> On Tue, 2011-08-16 at 11:24 -0700, David Daney wrote:
> > In pcibios_get_phb_of_node(), we will crash while booting if
> > bus->bridge->parent is NULL.
> > 
> > Check for this case and avoid dereferencing the NULL pointer.
> > 
> > Signed-off-by: David Daney <david.daney@cavium.com>
> 
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> 
> Jesse or Grant, I'm travelling, can any of you send that to Linus
> asap ?

Sure looks fine.  I'll send it off tomorrow (now that I'm back :).

Thanks,
Jesse

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pci/of: Don't crash when bridge parent is NULL.
  2011-08-17  4:11   ` Jesse Barnes
@ 2011-08-17 11:29     ` Grant Likely
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2011-08-17 11:29 UTC (permalink / raw)
  To: Jesse Barnes
  Cc: Benjamin Herrenschmidt, David Daney, linux-kernel, linux-pci,
	Grant Likely

On 11-08-16 10:11 PM, Jesse Barnes wrote:
> On Tue, 16 Aug 2011 14:16:18 -0500
> Benjamin Herrenschmidt<benh@kernel.crashing.org>  wrote:
>
>> On Tue, 2011-08-16 at 11:24 -0700, David Daney wrote:
>>> In pcibios_get_phb_of_node(), we will crash while booting if
>>> bus->bridge->parent is NULL.
>>>
>>> Check for this case and avoid dereferencing the NULL pointer.
>>>
>>> Signed-off-by: David Daney<david.daney@cavium.com>
>>
>> Acked-by: Benjamin Herrenschmidt<benh@kernel.crashing.org>
>>
>> Jesse or Grant, I'm travelling, can any of you send that to Linus
>> asap ?
>
> Sure looks fine.  I'll send it off tomorrow (now that I'm back :).
>
> Thanks,
> Jesse

thanks Jesse.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-17 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-16 18:24 [PATCH] pci/of: Don't crash when bridge parent is NULL David Daney
2011-08-16 19:16 ` Benjamin Herrenschmidt
2011-08-17  4:11   ` Jesse Barnes
2011-08-17 11:29     ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).