Skip to content

Commit

Permalink
net: dsa: Fix off-by-one in switch address parsing
Browse files Browse the repository at this point in the history
cd->sw_addr is used as a MDIO bus address, which cannot exceed
PHY_MAX_ADDR (32), our check was off-by-one.

Fixes: 5e95329 ("dsa: add device tree bindings to register DSA switches")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Jul 12, 2015
1 parent 8f5063e commit c8cf89f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c8cf89f

Please sign in to comment.