Commit a72eb546 authored by Florian Fainelli's avatar Florian Fainelli Committed by Luis Henriques

net: dsa: Test array index before use

commit 8f5063e9 upstream.

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: 5e95329b: ("dsa: add device tree bindings to register DSA switches")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 25516aec
......@@ -427,6 +427,8 @@ static int dsa_of_probe(struct platform_device *pdev)
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)
......@@ -449,8 +451,6 @@ static int dsa_of_probe(struct platform_device *pdev)
goto out_free_chip;
}
if (port_index == DSA_MAX_PORTS)
break;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment