diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-07-13 15:30:28 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-07-13 15:30:51 +0200 |
commit | a5f36f6b0a4c2c6cd879d3e0d10572e86386a4db (patch) | |
tree | 1526329520952e8c635bd42a22f0efee6b0f72f7 /ifpps.c | |
parent | aa435eec4cfd1794438ea8593fff0181c70dcebf (diff) |
ifpps: release stats on exit
The stack trace of valgrind --leak-check=full --show-reachable=yes ifpps \
-lpcd wlan0 showed that at exit members from stats are still reachable.
They have been alloced through stats_alloc, but not freed.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'ifpps.c')
-rw-r--r-- | ifpps.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -201,6 +201,22 @@ static void stats_zero(struct ifstat *stats, int cpus) STATS_ZERO1(cpu_iow); } +#define STATS_RELEASE(member) \ + do { xfree(stats->member); } while (0) + +static void stats_release(struct ifstat *stats) +{ + STATS_RELEASE(irqs); + STATS_RELEASE(irqs_srx); + STATS_RELEASE(irqs_stx); + + STATS_RELEASE(cpu_user); + STATS_RELEASE(cpu_sys); + STATS_RELEASE(cpu_nice); + STATS_RELEASE(cpu_idle); + STATS_RELEASE(cpu_iow); +} + static int stats_proc_net_dev(const char *ifname, struct ifstat *stats) { int ret = -EINVAL; @@ -1373,6 +1389,10 @@ int main(int argc, char **argv) if (promisc) leave_promiscuous_mode(ifname, ifflags); + stats_release(&stats_old); + stats_release(&stats_new); + stats_release(&stats_delta); + xfree(ifname); return ret; } |