Skip to content

Commit 5f64a7d

Browse files
ffainellidavem330
authored andcommitted
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 <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2116824 commit 5f64a7d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎net/dsa/dsa.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,11 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
350350

351351
for (i = 0; i < pd->nr_chips; i++) {
352352
port_index = 0;
353-
while (pd->chip[i].port_names &&
354-
pd->chip[i].port_names[++port_index])
355-
kfree(pd->chip[i].port_names[port_index]);
353+
while (port_index < DSA_MAX_PORTS) {
354+
if (pd->chip[i].port_names[port_index])
355+
kfree(pd->chip[i].port_names[port_index]);
356+
port_index++;
357+
}
356358
kfree(pd->chip[i].rtable);
357359
}
358360
kfree(pd->chip);

0 commit comments

Comments
 (0)