diff options
| author | Florian Fainelli <[email protected]> | 2013-03-25 05:03:40 +0000 |
|---|---|---|
| committer | David S. Miller <[email protected]> | 2013-03-25 16:23:41 +0000 |
| commit | 5f64a7dbf593c2317f132c8252d04cdfe8d4b104 (patch) | |
| tree | 544ab11b3ab0f788ae8a7e087b62ac4590579785 /net/dsa/dsa.c | |
| parent | dsa: factor freeing of dsa_platform_data (diff) | |
| download | kernel-5f64a7dbf593c2317f132c8252d04cdfe8d4b104.tar.gz kernel-5f64a7dbf593c2317f132c8252d04cdfe8d4b104.zip | |
dsa: fix freeing of sparse port allocation
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/dsa/dsa.c')
| -rw-r--r-- | net/dsa/dsa.c | 8 |
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); |
