[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B71B3@saturn3.aculab.com>
Date: Mon, 25 Mar 2013 16:03:23 -0000
From: "David Laight" <David.Laight@...LAB.COM>
To: "Florian Fainelli" <florian@...nwrt.org>, <davem@...emloft.net>
Cc: <netdev@...r.kernel.org>
Subject: RE: [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.
...
> 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++;
> + }
A couple of 'odd' differences:
The old code checked pd->chip[i].port_names (as if it
might be a pointer) that is absent from the new version.
(If it is separately allocated it is leaked).
The new code tests and frees pd->chip[i].port_names[0]
whereas the old code ignored the 0th entry.
These may, or may not, be relevant!
David
--
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