diff mbox

[iproute2,1/2] libs: close file in netns_switch()

Message ID 1439521013-22260-2-git-send-email-zhangshengju@cmss.chinamobile.com
State Changes Requested, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Zhang Shengju Aug. 14, 2015, 2:56 a.m. UTC
Add mising close() calls.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
 lib/namespace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stephen Hemminger Aug. 19, 2015, 11:36 p.m. UTC | #1
On Fri, 14 Aug 2015 02:56:52 +0000
Zhang Shengju <zhangshengju@cmss.chinamobile.com> wrote:

> Add mising close() calls.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>

Patch does not apply cleanly to current git code.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/namespace.c b/lib/namespace.c
index 8197165..025ed47 100644
--- a/lib/namespace.c
+++ b/lib/namespace.c
@@ -45,7 +45,7 @@  static void bind_etc(const char *name)
 int netns_switch(char *name)
 {
 	char net_path[PATH_MAX];
-	int netns;
+	int netns, ret = -1;
 
 	snprintf(net_path, sizeof(net_path), "%s/%s", NETNS_RUN_DIR, name);
 	netns = open(net_path, O_RDONLY | O_CLOEXEC);
@@ -83,10 +83,10 @@  int netns_switch(char *name)
 
 	/* Setup bind mounts for config files in /etc */
 	bind_etc(name);
-	return 0;
+	ret = 0;
 fail_close:
 	close(netns);
-	return -1;
+	return ret;
 }
 
 int netns_get_fd(const char *name)