af_packet: fix coverity error

Fix coverity error associated with fd.

Change-Id: I0648aebaf356308bc03cc7217922479bfc4e22f7
Signed-off-by: Ray Kinsella <ray.kinsella@intel.com>
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 4607d88..e01b1c7 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -212,6 +212,13 @@
   int rv, fd = socket (AF_UNIX, SOCK_DGRAM, 0);
   struct ifreq ifr;
 
+  if (0 > fd)
+    {
+      clib_unix_warning ("af_packet_%s could not open socket",
+			 apif->host_if_name);
+      return 0;
+    }
+
   /* if interface is a bridge ignore */
   if (apif->host_if_index < 0)
     goto error;			/* no error */
@@ -255,7 +262,8 @@
   vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
 
 error:
-  close (fd);
+  if (0 <= fd)
+    close (fd);
 
   return 0;			/* no error */
 }
@@ -278,6 +286,13 @@
   int rv, fd = socket (AF_UNIX, SOCK_DGRAM, 0);
   struct ifreq ifr;
 
+  if (0 > fd)
+    {
+      clib_unix_warning ("af_packet_%s could not open socket",
+			 apif->host_if_name);
+      return 0;
+    }
+
   /* if interface is a bridge ignore */
   if (apif->host_if_index < 0)
     goto error;			/* no error */
@@ -303,7 +318,9 @@
     }
 
 error:
-  close (fd);
+
+  if (0 <= fd)
+    close (fd);
 
   return 0;			/* no error */
 }