linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type()
@ 2020-08-04 12:04 Geert Uytterhoeven
  2020-08-04 15:13 ` Rob Herring
  2020-08-04 16:13 ` Lorenzo Pieralisi
  0 siblings, 2 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2020-08-04 12:04 UTC (permalink / raw)
  To: Rob Herring, Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi,
	Bjorn Helgaas
  Cc: linux-pci, linux-renesas-soc, linux-kernel, Geert Uytterhoeven

The conversion to modern host bridge probing made the driver allocate
its private data using devm_pci_alloc_host_bridge(), but forgot to
remove the old allocation.  Hence part of the driver initialization is
done using the new instance, while another part is done using the old
instance, leading to a crash due to uninitialized bridge DMA ranges:

    Unable to handle kernel NULL pointer dereference at virtual address 00000008
    pgd = (ptrval)
    [00000008] *pgd=00000000
    Internal error: Oops: 5 [#1] SMP ARM
    CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
    Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
    PC is at rcar_pci_probe+0x154/0x340
    LR is at _raw_spin_unlock_irqrestore+0x18/0x20

Fix this by dropping the old allocation.

Fixes: 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/pci/controller/pci-rcar-gen2.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/pci/controller/pci-rcar-gen2.c b/drivers/pci/controller/pci-rcar-gen2.c
index 046965d284a6d54e..c9530038ca9a53fc 100644
--- a/drivers/pci/controller/pci-rcar-gen2.c
+++ b/drivers/pci/controller/pci-rcar-gen2.c
@@ -302,10 +302,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
 	if (mem_res->start & 0xFFFF)
 		return -EINVAL;
 
-	priv = devm_kzalloc(dev, sizeof(struct rcar_pci_priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
 	priv->mem_res = *mem_res;
 	priv->cfg_res = cfg_res;
 
-- 
2.17.1


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

* Re: [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type()
  2020-08-04 12:04 [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type() Geert Uytterhoeven
@ 2020-08-04 15:13 ` Rob Herring
  2020-08-04 16:13 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 5+ messages in thread
From: Rob Herring @ 2020-08-04 15:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi, Bjorn Helgaas,
	PCI, open list:MEDIA DRIVERS FOR RENESAS - FCP, linux-kernel

On Tue, Aug 4, 2020 at 6:04 AM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> The conversion to modern host bridge probing made the driver allocate
> its private data using devm_pci_alloc_host_bridge(), but forgot to
> remove the old allocation.  Hence part of the driver initialization is
> done using the new instance, while another part is done using the old
> instance, leading to a crash due to uninitialized bridge DMA ranges:
>
>     Unable to handle kernel NULL pointer dereference at virtual address 00000008
>     pgd = (ptrval)
>     [00000008] *pgd=00000000
>     Internal error: Oops: 5 [#1] SMP ARM
>     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at rcar_pci_probe+0x154/0x340
>     LR is at _raw_spin_unlock_irqrestore+0x18/0x20
>
> Fix this by dropping the old allocation.
>
> Fixes: 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/pci/controller/pci-rcar-gen2.c | 4 ----
>  1 file changed, 4 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type()
  2020-08-04 12:04 [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type() Geert Uytterhoeven
  2020-08-04 15:13 ` Rob Herring
@ 2020-08-04 16:13 ` Lorenzo Pieralisi
  2020-08-04 16:22   ` Bjorn Helgaas
  1 sibling, 1 reply; 5+ messages in thread
From: Lorenzo Pieralisi @ 2020-08-04 16:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rob Herring, Marek Vasut, Yoshihiro Shimoda, Bjorn Helgaas,
	linux-pci, linux-renesas-soc, linux-kernel

On Tue, Aug 04, 2020 at 02:04:30PM +0200, Geert Uytterhoeven wrote:
> The conversion to modern host bridge probing made the driver allocate
> its private data using devm_pci_alloc_host_bridge(), but forgot to
> remove the old allocation.  Hence part of the driver initialization is
> done using the new instance, while another part is done using the old
> instance, leading to a crash due to uninitialized bridge DMA ranges:
> 
>     Unable to handle kernel NULL pointer dereference at virtual address 00000008
>     pgd = (ptrval)
>     [00000008] *pgd=00000000
>     Internal error: Oops: 5 [#1] SMP ARM
>     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
>     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
>     PC is at rcar_pci_probe+0x154/0x340
>     LR is at _raw_spin_unlock_irqrestore+0x18/0x20
> 
> Fix this by dropping the old allocation.
> 
> Fixes: 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/pci/controller/pci-rcar-gen2.c | 4 ----
>  1 file changed, 4 deletions(-)

Squashed in the initial commit, pushed out on pci/misc.

Thanks,
Lorenzo

> diff --git a/drivers/pci/controller/pci-rcar-gen2.c b/drivers/pci/controller/pci-rcar-gen2.c
> index 046965d284a6d54e..c9530038ca9a53fc 100644
> --- a/drivers/pci/controller/pci-rcar-gen2.c
> +++ b/drivers/pci/controller/pci-rcar-gen2.c
> @@ -302,10 +302,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
>  	if (mem_res->start & 0xFFFF)
>  		return -EINVAL;
>  
> -	priv = devm_kzalloc(dev, sizeof(struct rcar_pci_priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -
>  	priv->mem_res = *mem_res;
>  	priv->cfg_res = cfg_res;
>  
> -- 
> 2.17.1
> 

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

* Re: [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type()
  2020-08-04 16:13 ` Lorenzo Pieralisi
@ 2020-08-04 16:22   ` Bjorn Helgaas
  2020-08-04 16:48     ` Rob Herring
  0 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2020-08-04 16:22 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Rob Herring
  Cc: Geert Uytterhoeven, Marek Vasut, Yoshihiro Shimoda,
	Bjorn Helgaas, linux-pci, linux-renesas-soc, linux-kernel

On Tue, Aug 04, 2020 at 05:13:25PM +0100, Lorenzo Pieralisi wrote:
> On Tue, Aug 04, 2020 at 02:04:30PM +0200, Geert Uytterhoeven wrote:
> > The conversion to modern host bridge probing made the driver allocate
> > its private data using devm_pci_alloc_host_bridge(), but forgot to
> > remove the old allocation.  Hence part of the driver initialization is
> > done using the new instance, while another part is done using the old
> > instance, leading to a crash due to uninitialized bridge DMA ranges:
> > 
> >     Unable to handle kernel NULL pointer dereference at virtual address 00000008
> >     pgd = (ptrval)
> >     [00000008] *pgd=00000000
> >     Internal error: Oops: 5 [#1] SMP ARM
> >     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
> >     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
> >     PC is at rcar_pci_probe+0x154/0x340
> >     LR is at _raw_spin_unlock_irqrestore+0x18/0x20
> > 
> > Fix this by dropping the old allocation.
> > 
> > Fixes: 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> >  drivers/pci/controller/pci-rcar-gen2.c | 4 ----
> >  1 file changed, 4 deletions(-)
> 
> Squashed in the initial commit, pushed out on pci/misc.

I updated my 'next' branch with this.

Rob, are there any similar issues in other drivers that we should fix
before asking Linus to pull this?

> > diff --git a/drivers/pci/controller/pci-rcar-gen2.c b/drivers/pci/controller/pci-rcar-gen2.c
> > index 046965d284a6d54e..c9530038ca9a53fc 100644
> > --- a/drivers/pci/controller/pci-rcar-gen2.c
> > +++ b/drivers/pci/controller/pci-rcar-gen2.c
> > @@ -302,10 +302,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
> >  	if (mem_res->start & 0xFFFF)
> >  		return -EINVAL;
> >  
> > -	priv = devm_kzalloc(dev, sizeof(struct rcar_pci_priv), GFP_KERNEL);
> > -	if (!priv)
> > -		return -ENOMEM;
> > -
> >  	priv->mem_res = *mem_res;
> >  	priv->cfg_res = cfg_res;
> >  
> > -- 
> > 2.17.1
> > 

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

* Re: [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type()
  2020-08-04 16:22   ` Bjorn Helgaas
@ 2020-08-04 16:48     ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2020-08-04 16:48 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Geert Uytterhoeven, Marek Vasut,
	Yoshihiro Shimoda, Bjorn Helgaas, PCI,
	open list:MEDIA DRIVERS FOR RENESAS - FCP, linux-kernel

On Tue, Aug 4, 2020 at 10:22 AM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Tue, Aug 04, 2020 at 05:13:25PM +0100, Lorenzo Pieralisi wrote:
> > On Tue, Aug 04, 2020 at 02:04:30PM +0200, Geert Uytterhoeven wrote:
> > > The conversion to modern host bridge probing made the driver allocate
> > > its private data using devm_pci_alloc_host_bridge(), but forgot to
> > > remove the old allocation.  Hence part of the driver initialization is
> > > done using the new instance, while another part is done using the old
> > > instance, leading to a crash due to uninitialized bridge DMA ranges:
> > >
> > >     Unable to handle kernel NULL pointer dereference at virtual address 00000008
> > >     pgd = (ptrval)
> > >     [00000008] *pgd=00000000
> > >     Internal error: Oops: 5 [#1] SMP ARM
> > >     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
> > >     Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
> > >     PC is at rcar_pci_probe+0x154/0x340
> > >     LR is at _raw_spin_unlock_irqrestore+0x18/0x20
> > >
> > > Fix this by dropping the old allocation.
> > >
> > > Fixes: 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions")
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > >  drivers/pci/controller/pci-rcar-gen2.c | 4 ----
> > >  1 file changed, 4 deletions(-)
> >
> > Squashed in the initial commit, pushed out on pci/misc.
>
> I updated my 'next' branch with this.
>
> Rob, are there any similar issues in other drivers that we should fix
> before asking Linus to pull this?

I'd expect only different issues. :)

This commit is unique as it was using the old arm32 PCI functions and
the most complicated change of the lot.

Rob

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

end of thread, other threads:[~2020-08-04 16:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 12:04 [PATCH] PCI: rcar-gen2: Fix crash in resource_list_first_type() Geert Uytterhoeven
2020-08-04 15:13 ` Rob Herring
2020-08-04 16:13 ` Lorenzo Pieralisi
2020-08-04 16:22   ` Bjorn Helgaas
2020-08-04 16:48     ` Rob Herring

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).