[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1364223820-26051-4-git-send-email-florian@openwrt.org>
Date: Mon, 25 Mar 2013 16:03:40 +0100
From: Florian Fainelli <florian@...nwrt.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, Florian Fainelli <florian@...nwrt.org>
Subject: [PATCH 3/3] 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@...nwrt.org>
---
net/dsa/dsa.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index aa2ff58..0eb5d5e 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);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists