From deb80322ea62942f4f7b3dec3e38b0290aeee34d Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Tue, 16 Dec 2014 14:49:45 +0200 Subject: [PATCH] monitor: Fix memory leak Memory allocated l_timeout struct from l_timeout_create not being freed. ==4184== HEAP SUMMARY: ==4184== in use at exit: 32 bytes in 1 blocks ==4184== total heap usage: 50 allocs, 49 frees, 39,902 bytes allocated ==4184== ==4184== 32 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==4184== at 0x4C2ABA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==4184== by 0x40706D: l_malloc (util.c:62) ==4184== by 0x408D9A: l_timeout_create (timeout.c:117) ==4184== by 0x40896A: signal_callback (signal.c:82) ==4184== by 0x408692: l_main_run (main.c:346) ==4184== by 0x402474: main (main.c:797) ==4184== ==4184== LEAK SUMMARY: ==4184== definitely lost: 32 bytes in 1 blocks ==4184== indirectly lost: 0 bytes in 0 blocks ==4184== possibly lost: 0 bytes in 0 blocks ==4184== still reachable: 0 bytes in 0 blocks ==4184== suppressed: 0 bytes in 0 blocks --- monitor/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monitor/main.c b/monitor/main.c index 93b1f5f8..1d579150 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -44,6 +44,7 @@ static struct nlmon *nlmon = NULL; static const char *writer_path = NULL; +static struct l_timeout *timeout = NULL; #define NLA_OK(nla,len) ((len) >= (int) sizeof(struct nlattr) && \ (nla)->nla_len >= sizeof(struct nlattr) && \ @@ -652,7 +653,7 @@ static void signal_handler(struct l_signal *signal, uint32_t signo, case SIGTERM: iwmon_interface_disable(monitor_interface); - l_timeout_create(1, main_loop_quit, NULL, NULL); + timeout = l_timeout_create(1, main_loop_quit, NULL, NULL); break; } } @@ -806,6 +807,7 @@ int main(int argc, char *argv[]) done: l_signal_remove(signal); + l_free(timeout); return exit_status; }