From: Ben Pfaff Date: Fri, 29 Apr 2011 22:53:36 +0000 (-0700) Subject: netdev-linux: Only call set_nonblocking() if socket creation succeeds. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd3932826b3d9153f6d026adaad2439ac23f2fcd;p=openvswitch netdev-linux: Only call set_nonblocking() if socket creation succeeds. Reviewed-by: Simon Horman --- diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 384fdafe..1c5ddc53 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -451,11 +451,12 @@ netdev_linux_init(void) /* Create AF_PACKET socket. */ af_packet_sock = socket(AF_PACKET, SOCK_RAW, 0); status = af_packet_sock >= 0 ? 0 : errno; - if (status) { + if (!status) { + set_nonblocking(af_packet_sock); + } else { VLOG_ERR("failed to create packet socket: %s", strerror(status)); } - set_nonblocking(af_packet_sock); } /* Create rtnetlink socket. */