netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 0/2] Add missing file close
@ 2015-08-14  2:56 Zhang Shengju
  2015-08-14  2:56 ` [PATCH iproute2 1/2] libs: close file in netns_switch() Zhang Shengju
  2015-08-14  2:56 ` [PATCH iproute2 2/2] netns: add missing file close Zhang Shengju
  0 siblings, 2 replies; 4+ messages in thread
From: Zhang Shengju @ 2015-08-14  2:56 UTC (permalink / raw)
  To: netdev

This patch set adds some missing close() calls.

Zhang Shengju (2):
  libs: close file in netns_switch()
  netns: add missing file close

 ip/ipnetns.c    | 5 +++++
 lib/namespace.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH iproute2 1/2] libs: close file in netns_switch()
  2015-08-14  2:56 [PATCH iproute2 0/2] Add missing file close Zhang Shengju
@ 2015-08-14  2:56 ` Zhang Shengju
  2015-08-19 23:36   ` Stephen Hemminger
  2015-08-14  2:56 ` [PATCH iproute2 2/2] netns: add missing file close Zhang Shengju
  1 sibling, 1 reply; 4+ messages in thread
From: Zhang Shengju @ 2015-08-14  2:56 UTC (permalink / raw)
  To: netdev

Add mising close() calls.

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

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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH iproute2 2/2] netns: add missing file close
  2015-08-14  2:56 [PATCH iproute2 0/2] Add missing file close Zhang Shengju
  2015-08-14  2:56 ` [PATCH iproute2 1/2] libs: close file in netns_switch() Zhang Shengju
@ 2015-08-14  2:56 ` Zhang Shengju
  1 sibling, 0 replies; 4+ messages in thread
From: Zhang Shengju @ 2015-08-14  2:56 UTC (permalink / raw)
  To: netdev

Add missing file close.

Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
---
 ip/ipnetns.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 088096f..d1af0c6 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -462,8 +462,10 @@ static int netns_pids(int argc, char **argv)
 	if (fstat(netns, &netst) < 0) {
 		fprintf(stderr, "Stat of netns failed: %s\n",
 			strerror(errno));
+		close(netns);
 		return -1;
 	}
+	close(netns);
 	dir = opendir("/proc/");
 	if (!dir) {
 		fprintf(stderr, "Open of /proc failed: %s\n",
@@ -522,8 +524,10 @@ static int netns_identify(int argc, char **argv)
 	if (fstat(netns, &netst) < 0) {
 		fprintf(stderr, "Stat of netns failed: %s\n",
 			strerror(errno));
+		close(netns);
 		return -1;
 	}
+	close(netns);
 	dir = opendir(NETNS_RUN_DIR);
 	if (!dir) {
 		/* Succeed treat a missing directory as an empty directory */
@@ -728,6 +732,7 @@ static int netns_set(int argc, char **argv)
 			name, strerror(errno));
 		return -1;
 	}
+	close(netns);
 
 	return set_netnsid_from_name(name, nsid);
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 1/2] libs: close file in netns_switch()
  2015-08-14  2:56 ` [PATCH iproute2 1/2] libs: close file in netns_switch() Zhang Shengju
@ 2015-08-19 23:36   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2015-08-19 23:36 UTC (permalink / raw)
  To: Zhang Shengju; +Cc: netdev

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-19 23:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14  2:56 [PATCH iproute2 0/2] Add missing file close Zhang Shengju
2015-08-14  2:56 ` [PATCH iproute2 1/2] libs: close file in netns_switch() Zhang Shengju
2015-08-19 23:36   ` Stephen Hemminger
2015-08-14  2:56 ` [PATCH iproute2 2/2] netns: add missing file close Zhang Shengju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).