summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorSteven <sluong@cisco.com>2017-12-02 20:17:27 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-04 11:27:03 +0000
commit37eba0db4262eb5cb63be8911f1af845b845739b (patch)
tree4c392910ebc55e84d6f1446e3725476c27a4eb56 /src/vnet/devices
parent87c30d9c1072a3305d0385e9ba8eb1b60fb068ce (diff)
tap_v2: coverity strikes, again!
fd is not close when IOCTL encounters an error which causes resource leak. The fix is to initialize fd to -1. At return, close fd if it has a valid value. Change-Id: I53c4f5c71ca0f556fb6586f5849e7cb622632d8f Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/virtio/tap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vnet/devices/virtio/tap.c b/src/vnet/devices/virtio/tap.c
index cc28df3be7f..0eaaf2771cc 100644
--- a/src/vnet/devices/virtio/tap.c
+++ b/src/vnet/devices/virtio/tap.c
@@ -60,7 +60,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
virtio_main_t *vim = &virtio_main;
vnet_sw_interface_t *sw;
vnet_hw_interface_t *hw;
- int i, fd;
+ int i, fd = -1;
struct ifreq ifr;
size_t hdrsz;
struct vhost_memory *vhost_mem = 0;
@@ -205,7 +205,6 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
_IOCTL (fd, SIOCGIFFLAGS, (void *) &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
_IOCTL (fd, SIOCSIFFLAGS, (void *) &ifr);
- close (fd);
}
if (!args->hw_addr_set)
@@ -268,6 +267,8 @@ error:
done:
if (vhost_mem)
clib_mem_free (vhost_mem);
+ if (fd != -1)
+ close (fd);
}
int