diff mbox

iproute2: Fix memory hog of ip batched command.

Message ID 20120713091002.3729398e@nehalam.linuxnetplumber.net
State RFC, archived
Delegated to: stephen hemminger
Headers show

Commit Message

stephen hemminger July 13, 2012, 4:10 p.m. UTC
On Thu, 12 Jul 2012 18:21:06 -0700
Pravin B Shelar <pshelar@nicira.com> wrote:

> ipaddr_list_or_flush() builds list of all device at start of
> every flush or list operation, but does not free memory at end.
> This can hog lot of memory for large batched command.
> Following patch fixes it.
> 
> Reported-by: Justin Pettit <jpettit@nicira.com>
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>


Given all the conditional's and goto's this introduces, I prefer to
refactor the code to split up the large function. 


There is an additional leak here where element is pruned from list and not freed.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 1db7fd0..5e03d1e 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1011,9 +1011,10 @@  flush_done:
                                ok = 1;
                                break;
                        }
-                       if (!ok)
+                       if (!ok) {
                                *lp = l->next;
-                       else
+                               free(l);
+                       } else
                                lp = &l->next;
                }
        }