Skip to content

Commit

Permalink
dsa: fix freeing of sparse port allocation
Browse files Browse the repository at this point in the history
If we have defined a sparse port allocation which is non-contiguous and
contains gaps, the code freeing port_names will just stop when it
encouters a first NULL port_names, which is not right, we should iterate
over all possible number of ports (DSA_MAX_PORTS) until we are done.

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 Mar 25, 2013
1 parent 2116824 commit 5f64a7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5f64a7d

Please sign in to comment.