diff mbox

mvebu : pcie: dt: potential issue in range parsing

Message ID 1389349431-7997-1-git-send-email-jjhiblot@traphandler.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jean-Jacques Hiblot Jan. 10, 2014, 10:23 a.m. UTC
The second parameter of of_read_number is not the index, but a size.
As it happens, in this case it may work just fine because of the the conversion
to u32 and the favorable endianness on this architecture.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
---
 drivers/pci/host/pci-mvebu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jason Cooper Feb. 5, 2014, 4:05 a.m. UTC | #1
Jean-Jacques,

On Fri, Jan 10, 2014 at 11:23:51AM +0100, Jean-Jacques Hiblot wrote:
> The second parameter of of_read_number is not the index, but a size.
> As it happens, in this case it may work just fine because of the the conversion
> to u32 and the favorable endianness on this architecture.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> ---
>  drivers/pci/host/pci-mvebu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Sorry for the unusually long delay.  I was waiting for Thomas to get
back from vacation since he is intimately familiar with this driver.

Thomas?

thx,

Jason.

> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index c269e43..877e8ce 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -768,7 +768,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
>  
>  	for (i = 0; i < nranges; i++) {
>  		u32 flags = of_read_number(range, 1);
> -		u32 slot = of_read_number(range, 2);
> +		u32 slot = of_read_number(range + 1, 1);
>  		u64 cpuaddr = of_read_number(range + na, pna);
>  		unsigned long rtype;
>  
> -- 
> 1.8.5.2
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thomas Petazzoni Feb. 5, 2014, 3:47 p.m. UTC | #2
Dear Jean-Jacques Hiblot,

On Fri, 10 Jan 2014 11:23:51 +0100, Jean-Jacques Hiblot wrote:
> The second parameter of of_read_number is not the index, but a size.
> As it happens, in this case it may work just fine because of the the conversion
> to u32 and the favorable endianness on this architecture.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> ---
>  drivers/pci/host/pci-mvebu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index c269e43..877e8ce 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -768,7 +768,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
>  
>  	for (i = 0; i < nranges; i++) {
>  		u32 flags = of_read_number(range, 1);
> -		u32 slot = of_read_number(range, 2);
> +		u32 slot = of_read_number(range + 1, 1);
>  		u64 cpuaddr = of_read_number(range + na, pna);
>  		unsigned long rtype;
>  

Sorry for the long delay, and thanks for the fix!

Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

(on Armada 370, with PCIe cards plugged in)

Thanks!

Thomas
Jason Cooper Feb. 5, 2014, 5:21 p.m. UTC | #3
+ Bjorn, linux-pci

Bjorn,

It looks like this didn't get Cc'd to linux-pci.  Here's a link:

  http://www.spinics.net/lists/arm-kernel/msg299721.html

On Wed, Feb 05, 2014 at 04:47:10PM +0100, Thomas Petazzoni wrote:
> Dear Jean-Jacques Hiblot,
> 
> On Fri, 10 Jan 2014 11:23:51 +0100, Jean-Jacques Hiblot wrote:
> > The second parameter of of_read_number is not the index, but a size.
> > As it happens, in this case it may work just fine because of the the conversion
> > to u32 and the favorable endianness on this architecture.
> > 
> > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> > ---
> >  drivers/pci/host/pci-mvebu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> > index c269e43..877e8ce 100644
> > --- a/drivers/pci/host/pci-mvebu.c
> > +++ b/drivers/pci/host/pci-mvebu.c
> > @@ -768,7 +768,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
> >  
> >  	for (i = 0; i < nranges; i++) {
> >  		u32 flags = of_read_number(range, 1);
> > -		u32 slot = of_read_number(range, 2);
> > +		u32 slot = of_read_number(range + 1, 1);
> >  		u64 cpuaddr = of_read_number(range + na, pna);
> >  		unsigned long rtype;
> >  
> 
> Sorry for the long delay, and thanks for the fix!
> 
> Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> 
> (on Armada 370, with PCIe cards plugged in)


Fixes: 11be65472a427 ("PCI: mvebu: Adapt to the new device tree layout")
Cc: <stable@vger.kernel.org> # v3.12+
Acked-by: Jason Cooper <jason@lakedaemon.net>

thx,

Jason.
Bjorn Helgaas Feb. 14, 2014, 6:51 p.m. UTC | #4
On Wed, Feb 05, 2014 at 12:21:07PM -0500, Jason Cooper wrote:
> 
> + Bjorn, linux-pci
> 
> Bjorn,
> 
> It looks like this didn't get Cc'd to linux-pci.  Here's a link:
> 
>   http://www.spinics.net/lists/arm-kernel/msg299721.html

Thanks for the heads-up; I had indeed missed this (I mostly rely on
patchwork, which only tracks linux-pci, and it's not smart enough to
extract quoted patches).

Applied to pci/host-mvebu for v3.15, thanks!

> 
> On Wed, Feb 05, 2014 at 04:47:10PM +0100, Thomas Petazzoni wrote:
> > Dear Jean-Jacques Hiblot,
> > 
> > On Fri, 10 Jan 2014 11:23:51 +0100, Jean-Jacques Hiblot wrote:
> > > The second parameter of of_read_number is not the index, but a size.
> > > As it happens, in this case it may work just fine because of the the conversion
> > > to u32 and the favorable endianness on this architecture.
> > > 
> > > Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
> > > ---
> > >  drivers/pci/host/pci-mvebu.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> > > index c269e43..877e8ce 100644
> > > --- a/drivers/pci/host/pci-mvebu.c
> > > +++ b/drivers/pci/host/pci-mvebu.c
> > > @@ -768,7 +768,7 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
> > >  
> > >  	for (i = 0; i < nranges; i++) {
> > >  		u32 flags = of_read_number(range, 1);
> > > -		u32 slot = of_read_number(range, 2);
> > > +		u32 slot = of_read_number(range + 1, 1);
> > >  		u64 cpuaddr = of_read_number(range + na, pna);
> > >  		unsigned long rtype;
> > >  
> > 
> > Sorry for the long delay, and thanks for the fix!
> > 
> > Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > 
> > (on Armada 370, with PCIe cards plugged in)
> 
> 
> Fixes: 11be65472a427 ("PCI: mvebu: Adapt to the new device tree layout")
> Cc: <stable@vger.kernel.org> # v3.12+
> Acked-by: Jason Cooper <jason@lakedaemon.net>
> 
> thx,
> 
> Jason.
diff mbox

Patch

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index c269e43..877e8ce 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -768,7 +768,7 @@  static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
 
 	for (i = 0; i < nranges; i++) {
 		u32 flags = of_read_number(range, 1);
-		u32 slot = of_read_number(range, 2);
+		u32 slot = of_read_number(range + 1, 1);
 		u64 cpuaddr = of_read_number(range + na, pna);
 		unsigned long rtype;