Commit f9bf5a2ca6cc331f32e3dd9cf16ced7215d0e6e8
Committed by
David S. Miller
1 parent
f490be049b
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff
net/dsa/dsa.c
... | ... | @@ -80,6 +80,7 @@ |
80 | 80 | int ret; |
81 | 81 | char *name; |
82 | 82 | int i; |
83 | + bool valid_name_found = false; | |
83 | 84 | |
84 | 85 | /* |
85 | 86 | * Probe for switch model. |
86 | 87 | |
... | ... | @@ -131,8 +132,13 @@ |
131 | 132 | } else { |
132 | 133 | ds->phys_port_mask |= 1 << i; |
133 | 134 | } |
135 | + valid_name_found = true; | |
134 | 136 | } |
135 | 137 | |
138 | + if (!valid_name_found && i == DSA_MAX_PORTS) { | |
139 | + ret = -EINVAL; | |
140 | + goto out; | |
141 | + } | |
136 | 142 | |
137 | 143 | /* |
138 | 144 | * If the CPU connects to this switch, set the switch tree |