[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120713091002.3729398e@nehalam.linuxnetplumber.net>
Date: Fri, 13 Jul 2012 09:10:02 -0700
From: Stephen Hemminger <shemminger@...tta.com>
To: Pravin B Shelar <pshelar@...ira.com>
Cc: netdev@...r.kernel.org, jpettit@...ira.com, jesse@...ira.com
Subject: Re: [PATCH] iproute2: Fix memory hog of ip batched command.
On Thu, 12 Jul 2012 18:21:06 -0700
Pravin B Shelar <pshelar@...ira.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@...ira.com>
> Signed-off-by: Pravin B Shelar <pshelar@...ira.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.
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;
}
}
--
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