summaryrefslogtreecommitdiff
path: root/net/dsa
diff options
context:
space:
mode:
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index aa2ff583b7ed..0eb5d5e76dfb 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -350,9 +350,11 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
for (i = 0; i < pd->nr_chips; i++) {
port_index = 0;
- while (pd->chip[i].port_names &&
- pd->chip[i].port_names[++port_index])
- kfree(pd->chip[i].port_names[port_index]);
+ while (port_index < DSA_MAX_PORTS) {
+ if (pd->chip[i].port_names[port_index])
+ kfree(pd->chip[i].port_names[port_index]);
+ port_index++;
+ }
kfree(pd->chip[i].rtable);
}
kfree(pd->chip);