Commit f9bf5a2c authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

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: default avatarFlorian Fainelli <florian@openwrt.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f490be04
......@@ -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
......
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