Skip to content

Commit

Permalink
dsa: make dsa_switch_setup check for valid port names
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Jan 21, 2013
1 parent f490be0 commit f9bf5a2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f9bf5a2

Please sign in to comment.