It's unlikely to fail but checking it can't hurt.

Found by Coverity.

Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 lib/netdev-linux.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 433d168..a1ddbe4 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -4586,7 +4586,11 @@ af_packet_sock(void)
     if (sock == INT_MIN) {
         sock = socket(AF_PACKET, SOCK_RAW, 0);
         if (sock >= 0) {
-            set_nonblocking(sock);
+            int error = set_nonblocking(sock);
+            if (error) {
+                close(sock);
+                sock = -error;
+            }
         } else {
             sock = -errno;
             VLOG_ERR("failed to create packet socket: %s", strerror(errno));
-- 
1.7.2.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to