summaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2013-01-21 10:58:51 +0100
committerDavid S. Miller <davem@davemloft.net>2013-01-21 21:40:12 +0100
commitf9bf5a2ca6cc331f32e3dd9cf16ced7215d0e6e8 (patch)
tree774573c6a730967410a51e954577424be0977fe6 /net/dsa
parentdsa: use an unique and non conflicting bus name for the slave MII bus (diff)
downloadlinux-f9bf5a2ca6cc331f32e3dd9cf16ced7215d0e6e8.tar.xz
linux-f9bf5a2ca6cc331f32e3dd9cf16ced7215d0e6e8.zip
dsa: make dsa_switch_setup check for valid port names
This patch changes dsa_switch_setup() to ensure that at least one valid valid port name is specified and will bail out with an error in case we walked the maximum number of port with a valid port name found. Signed-off-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 45295ca09571..2bc62ea857c8 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -80,6 +80,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
int ret;
char *name;
int i;
+ bool valid_name_found = false;
/*
* Probe for switch model.
@@ -131,8 +132,13 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
} else {
ds->phys_port_mask |= 1 << i;
}
+ valid_name_found = true;
}
+ if (!valid_name_found && i == DSA_MAX_PORTS) {
+ ret = -EINVAL;
+ goto out;
+ }
/*
* If the CPU connects to this switch, set the switch tree