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
This commit is contained in:
Ravi kumar Veeramally 2014-12-16 14:49:45 +02:00 committed by Denis Kenzior
parent 44301601ed
commit deb80322ea
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}