Thread (15 messages) 15 messages, 2 authors, 2011-11-03
STALE5345d

[PATCH 02/12] ping_monitor(): check file descriptor is valid before using and closing it

From: <hidden>
Date: 2011-11-02 14:42:07
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

Signed-off-by: Jes Sorensen <redacted>
---
 msg.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/msg.c b/msg.c
index 98d6d13..87d3b8d 100644
--- a/msg.c
+++ b/msg.c
@@ -207,9 +207,14 @@ int fping_monitor(int sfd)
 int ping_monitor(char *devname)
 {
 	int sfd = connect_monitor(devname);
-	int err = fping_monitor(sfd);
+	int err;
+
+	if (sfd >= 0) {
+		err = fping_monitor(sfd);
+		close(sfd);
+	} else
+		err = -1;
 
-	close(sfd);
 	return err;
 }
 
-- 
1.7.6.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help