[ovs-dev] [coverity 09/12] netdev-linux: Check return value of set_nonblocking().

Ben Pfaff blp at nicira.com
Thu Jan 24 22:44:34 UTC 2013


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

Found by Coverity.

Signed-off-by: Ben Pfaff <blp at 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




More information about the dev mailing list