summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorRay Kinsella <ray.kinsella@intel.com>2017-05-20 13:42:30 +0100
committerChris Luke <chris_luke@comcast.com>2017-05-25 02:39:00 +0000
commite6cc9cc77c9dcefa3d52e0cd90db35435f0eb64e (patch)
tree64e6a5e1fc40f020f6f46e83f6893264eba6edd5 /src/vnet/devices
parent922549afb4480842904dcebf51548f307951e1c2 (diff)
af_packet: fix coverity error
Fix coverity error associated with fd. Change-Id: I0648aebaf356308bc03cc7217922479bfc4e22f7 Signed-off-by: Ray Kinsella <ray.kinsella@intel.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/af_packet/device.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 4607d888..e01b1c71 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -212,6 +212,13 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
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 @@ af_packet_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index,
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 @@ static clib_error_t *af_packet_set_mac_address_function
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 @@ static clib_error_t *af_packet_set_mac_address_function
}
error:
- close (fd);
+
+ if (0 <= fd)
+ close (fd);
return 0; /* no error */
}