Patchwork bridge-utils: fix AF_LOCAL socket leaks

login
register
mail settings
Submitter Devendra Naga
Date April 4, 2013, 11:36 a.m.
Message ID <1365075386-2363-1-git-send-email-devendra.aaru@gmail.com>
Download mbox | patch
Permalink /patch/233721/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Devendra Naga - April 4, 2013, 11:36 a.m.
valgrind reported the following leak on fc18 system:

valgrind -v --leak-check=full --track-fds=yes ./brctl show

==27307==
==27307== FILE DESCRIPTORS: 4 open at exit.
==27307== Open AF_UNIX socket 3: <unknown>
==27307==    at 0x397B2F3617: socket (in /usr/lib64/libc-2.16.so)
==27307==    by 0x403CF7: br_init (libbridge_init.c:35)
==27307==    by 0x4010BF: main (brctl.c:63)

fix it by calling br_shutdown

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 brctl/brctl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch

diff --git a/brctl/brctl.c b/brctl/brctl.c
index 46ca352..16080a7 100644
--- a/brctl/brctl.c
+++ b/brctl/brctl.c
@@ -43,6 +43,7 @@  int main(int argc, char *const* argv)
 		{ .name = "version", .val = 'V' },
 		{ 0 }
 	};
+	int ret;
 
 	while ((f = getopt_long(argc, argv, "Vh", options, NULL)) != EOF) 
 		switch(f) {
@@ -79,7 +80,10 @@  int main(int argc, char *const* argv)
 		return 1;
 	}
 
-	return cmd->func(argc, argv);
+	ret = cmd->func(argc, argv);
+	br_shutdown();
+
+	return ret;
 
 help:
 	help();