From bd3932826b3d9153f6d026adaad2439ac23f2fcd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 29 Apr 2011 15:53:36 -0700 Subject: [PATCH] netdev-linux: Only call set_nonblocking() if socket creation succeeds. Reviewed-by: Simon Horman --- lib/netdev-linux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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. */ -- 2.30.2