Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 1/2] nfs-utils: libnsm.a: do not close file if open failed
@ 2015-12-02 11:16 Vivek Trivedi
  2015-12-02 11:16 ` [PATCH 2/2] nfs-utils: mount.nfs: fix null pointer derefernce in nfs_parse_simple_hostname Vivek Trivedi
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Vivek Trivedi @ 2015-12-02 11:16 UTC (permalink / raw)
  To: linux-nfs; +Cc: a.sahrawat, pankaj.m, Vivek Trivedi

If file open failed, no need to issue close system call in
nsm_get_state and closeall.

Signed-off-by: Vivek Trivedi <t.vivek@samsung.com>
---
 support/nfs/closeall.c |    3 ++-
 support/nsm/file.c     |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/support/nfs/closeall.c b/support/nfs/closeall.c
index 38fb162..a69bf35 100644
--- a/support/nfs/closeall.c
+++ b/support/nfs/closeall.c
@@ -31,6 +31,7 @@ closeall(int min)
 	} else {
 		int fd = sysconf(_SC_OPEN_MAX);
 		while (--fd >= min)
-			(void) close(fd);
+			if(fd >= 0)
+				(void) close(fd);
 	}
 }
diff --git a/support/nsm/file.c b/support/nsm/file.c
index 4711c2c..7a8b504 100644
--- a/support/nsm/file.c
+++ b/support/nsm/file.c
@@ -536,7 +536,8 @@ nsm_get_state(_Bool update)
 		state++;
 
 update:
-	(void)close(fd);
+	if(fd >= 0)
+		(void)close(fd);
 
 	if (update) {
 		state += 2;
-- 
1.7.9.5


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

end of thread, other threads:[~2015-12-12 12:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 11:16 [PATCH 1/2] nfs-utils: libnsm.a: do not close file if open failed Vivek Trivedi
2015-12-02 11:16 ` [PATCH 2/2] nfs-utils: mount.nfs: fix null pointer derefernce in nfs_parse_simple_hostname Vivek Trivedi
2015-12-02 16:16   ` Steve Dickson
2015-12-03 15:22     ` Vivek Trivedi
2015-12-12 12:12   ` Steve Dickson
2015-12-02 16:11 ` [PATCH 1/2] nfs-utils: libnsm.a: do not close file if open failed Steve Dickson
2015-12-03 15:21   ` Vivek Trivedi
2015-12-12 12:11 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox