net: dsa: OF parsing fixes
Subsystems (3)
cover net: dsa: OF parsing fixes
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(-)
Signature · 1 line
2.1.4
PATCH 1/2 net: dsa: Test array index before use
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.
--- net/dsa/dsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/dsa.c +2 -2
@@ -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 ; } }
Signature · 1 line
2.1.4
PATCH 2/2 net: dsa: Fix off-by-one in switch address parsing
In reply to Florian Fainellicd->sw_addr is used as a MDIO bus address, which cannot exceed PHY_MAX_ADDR (32), our check was off-by-one.
--- net/dsa/dsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/dsa/dsa.c +1 -1
@@ -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))
Signature · 1 line
2.1.4
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Sat, 11 Jul 2015 18:02:09 -0700
Quoted 3 lines
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.