netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: dsa: OF parsing fixes
@ 2015-07-12  1:02 Florian Fainelli
  2015-07-12  1:02 ` [PATCH net 1/2] net: dsa: Test array index before use Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Florian Fainelli @ 2015-07-12  1:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, linux, dan.carpenter, Florian Fainelli

Hi David,

This patch series fixes two small parsing issues, the first one was reported by
Dan, the second came after looking more closely at the code.

Thanks!

Florian Fainelli (2):
  net: dsa: Test array index before use
  net: dsa: Fix off-by-one in switch address parsing

 net/dsa/dsa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.1.4

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

* [PATCH net 1/2] net: dsa: Test array index before use
  2015-07-12  1:02 [PATCH net 0/2] net: dsa: OF parsing fixes Florian Fainelli
@ 2015-07-12  1:02 ` Florian Fainelli
  2015-07-12  1:02 ` [PATCH net 2/2] net: dsa: Fix off-by-one in switch address parsing Florian Fainelli
  2015-07-12  6:25 ` [PATCH net 0/2] net: dsa: OF parsing fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2015-07-12  1:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, linux, dan.carpenter, Florian Fainelli

port_index is used an index into an array, and this information comes
from Device Tree, make sure that port_index is not equal to the array
size before using it. Move the check against port_index earlier in the
loop.

Fixes: 5e95329b701c: ("dsa: add device tree bindings to register DSA switches")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/dsa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 392e29a0227d..52beeb8829dc 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -642,6 +642,8 @@ static int dsa_of_probe(struct device *dev)
 				continue;
 
 			port_index = be32_to_cpup(port_reg);
+			if (port_index >= DSA_MAX_PORTS)
+				break;
 
 			port_name = of_get_property(port, "label", NULL);
 			if (!port_name)
@@ -666,8 +668,6 @@ static int dsa_of_probe(struct device *dev)
 					goto out_free_chip;
 			}
 
-			if (port_index == DSA_MAX_PORTS)
-				break;
 		}
 	}
 
-- 
2.1.4

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

* [PATCH net 2/2] net: dsa: Fix off-by-one in switch address parsing
  2015-07-12  1:02 [PATCH net 0/2] net: dsa: OF parsing fixes Florian Fainelli
  2015-07-12  1:02 ` [PATCH net 1/2] net: dsa: Test array index before use Florian Fainelli
@ 2015-07-12  1:02 ` Florian Fainelli
  2015-07-12  6:25 ` [PATCH net 0/2] net: dsa: OF parsing fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2015-07-12  1:02 UTC (permalink / raw)
  To: netdev; +Cc: davem, andrew, linux, dan.carpenter, Florian Fainelli

cd->sw_addr is used as a MDIO bus address, which cannot exceed
PHY_MAX_ADDR (32), our check was off-by-one.

Fixes: 5e95329b701c ("dsa: add device tree bindings to register DSA switches")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/dsa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 52beeb8829dc..b445d492c115 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -630,7 +630,7 @@ static int dsa_of_probe(struct device *dev)
 			continue;
 
 		cd->sw_addr = be32_to_cpup(sw_addr);
-		if (cd->sw_addr > PHY_MAX_ADDR)
+		if (cd->sw_addr >= PHY_MAX_ADDR)
 			continue;
 
 		if (!of_property_read_u32(child, "eeprom-length", &eeprom_len))
-- 
2.1.4

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

* Re: [PATCH net 0/2] net: dsa: OF parsing fixes
  2015-07-12  1:02 [PATCH net 0/2] net: dsa: OF parsing fixes Florian Fainelli
  2015-07-12  1:02 ` [PATCH net 1/2] net: dsa: Test array index before use Florian Fainelli
  2015-07-12  1:02 ` [PATCH net 2/2] net: dsa: Fix off-by-one in switch address parsing Florian Fainelli
@ 2015-07-12  6:25 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-07-12  6:25 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, andrew, linux, dan.carpenter

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Sat, 11 Jul 2015 18:02:09 -0700

> This patch series fixes two small parsing issues, the first one was
> reported by Dan, the second came after looking more closely at the
> code.

Series applied, thanks Florian.

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

end of thread, other threads:[~2015-07-12  6:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-12  1:02 [PATCH net 0/2] net: dsa: OF parsing fixes Florian Fainelli
2015-07-12  1:02 ` [PATCH net 1/2] net: dsa: Test array index before use Florian Fainelli
2015-07-12  1:02 ` [PATCH net 2/2] net: dsa: Fix off-by-one in switch address parsing Florian Fainelli
2015-07-12  6:25 ` [PATCH net 0/2] net: dsa: OF parsing fixes David Miller

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