net: dsa: Test array index before use
authorFlorian Fainelli <f.fainelli@gmail.com>
Sun, 12 Jul 2015 01:02:10 +0000 (18:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 12 Jul 2015 06:25:16 +0000 (23:25 -0700)
commit8f5063e97f393d49611151d3cf7dcbeb41397f12
tree09864acdea8b4c1ef6ed6a9d4f0b159f25d9ef28
parent2ee94014d9bd3868b1c0d17405f96d63bec83f28
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.

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c