Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1346385 > unrolled thread

[PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM

Started bykhalasa@piap.pl (Krzysztof Hałasa)
First post2016-03-01 07:10 +0100
Last post2016-03-04 07:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM khalasa@piap.pl (Krzysztof Hałasa) - 2016-03-01 07:10 +0100
    Re: [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr()  on ARM Bjorn Helgaas <helgaas@kernel.org> - 2016-03-03 18:40 +0100
      Re: [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM khalasa@piap.pl (Krzysztof Hałasa) - 2016-03-04 07:20 +0100

#1346385 — [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM

Fromkhalasa@piap.pl (Krzysztof Hałasa)
Date2016-03-01 07:10 +0100
Subject[PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM
Message-ID<r7LFn-5iU-5@gated-at.bofh.it>
Many ARM platforms use a wrapper:
/*
 * Compatibility wrapper for older platforms that do not care about
 * passing the parent device.
 */
static inline void pci_common_init(struct hw_pci *hw)
{
        pci_common_init_dev(NULL, hw);
}

which means that pci_bus_assign_domain_nr() can be called without
a parent. This patch fixes the NULL pointer dereference.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
Cc: stable@vger.kernel.org

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 602eb42..f89db3a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4772,8 +4772,10 @@ int pci_get_new_domain_nr(void)
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 {
 	static int use_dt_domains = -1;
-	int domain = of_get_pci_domain_nr(parent->of_node);
+	int domain = -1;
 
+	if (parent)
+		domain = of_get_pci_domain_nr(parent->of_node);
 	/*
 	 * Check DT domain and use_dt_domains values.
 	 *

-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

[toc] | [next] | [standalone]


#1349444 — Re: [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM

FromBjorn Helgaas <helgaas@kernel.org>
Date2016-03-03 18:40 +0100
SubjectRe: [PATCH] Fix NULL ptr dereference in pci_bus_assign_domain_nr() on ARM
Message-ID<r8Fog-25V-45@gated-at.bofh.it>
In reply to#1346385
Hi Krzysztof,

On Tue, Mar 01, 2016 at 07:07:18AM +0100, Krzysztof Hałasa wrote:
> Many ARM platforms use a wrapper:
> /*
>  * Compatibility wrapper for older platforms that do not care about
>  * passing the parent device.
>  */
> static inline void pci_common_init(struct hw_pci *hw)
> {
>         pci_common_init_dev(NULL, hw);
> }
> 
> which means that pci_bus_assign_domain_nr() can be called without
> a parent. This patch fixes the NULL pointer dereference.

What exactly is the impact of this?  Does this fix need to be in v4.5?
It sounds like it should be, but I need a little more detailed
justification, e.g., "platforms X, Y, Z don't boot at all without
this change."

> Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
> Cc: stable@vger.kernel.org
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 602eb42..f89db3a 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4772,8 +4772,10 @@ int pci_get_new_domain_nr(void)
>  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  {
>  	static int use_dt_domains = -1;
> -	int domain = of_get_pci_domain_nr(parent->of_node);
> +	int domain = -1;
>  
> +	if (parent)
> +		domain = of_get_pci_domain_nr(parent->of_node);
>  	/*
>  	 * Check DT domain and use_dt_domains values.
>  	 *
> 
> -- 
> Krzysztof Halasa
> 
> Industrial Research Institute for Automation and Measurements PIAP
> Al. Jerozolimskie 202, 02-486 Warsaw, Poland

[toc] | [prev] | [next] | [standalone]


#1349875

Fromkhalasa@piap.pl (Krzysztof Hałasa)
Date2016-03-04 07:20 +0100
Message-ID<r8RfH-2o1-5@gated-at.bofh.it>
In reply to#1349444
Hi Bjorn,

Bjorn Helgaas <helgaas@kernel.org> writes:

> On Tue, Mar 01, 2016 at 07:07:18AM +0100, Krzysztof Hałasa wrote:
>> Many ARM platforms use a wrapper:
>> /*
>>  * Compatibility wrapper for older platforms that do not care about
>>  * passing the parent device.
>>  */
>> static inline void pci_common_init(struct hw_pci *hw)
>> {
>>         pci_common_init_dev(NULL, hw);
>> }
>> 
>> which means that pci_bus_assign_domain_nr() can be called without
>> a parent. This patch fixes the NULL pointer dereference.
>
> What exactly is the impact of this?  Does this fix need to be in v4.5?
> It sounds like it should be, but I need a little more detailed
> justification, e.g., "platforms X, Y, Z don't boot at all without
> this change."

At least CNS3xxx doesn't boot. I haven't verified a couple of others,
but they may be broken as well.
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web