summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/tap/tap.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-06-27 17:31:28 +0200
committerNeale Ranns <nranns@cisco.com>2019-06-28 11:58:12 +0000
commit8d879e1a6bac47240a232893e914815f781fd4bf (patch)
tree3bcbeabe6a3438b03ec631de75efdbdaf8c257b3 /src/vnet/devices/tap/tap.c
parent4752b29cfe229806c1cb2ae852c188d36be4c7cf (diff)
tap: fix memory errors in create/delete
If the host interface name is not specified at creation, host_if_name was wrongly set to a stack-allocated variable. Make sure it always points to a heap allocated vector. At deletion time, we must free all allocated vectors. Type:fix Change-Id: I17751f38e95097998d51225fdccbf3ce3c365593 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vnet/devices/tap/tap.c')
-rw-r--r--src/vnet/devices/tap/tap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index 8dc798a3cb3..38ac0f93682 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -208,7 +208,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
vif->ifindex = if_nametoindex (ifr.ifr_ifrn.ifrn_name);
if (!args->host_if_name)
- args->host_if_name = (u8 *) ifr.ifr_ifrn.ifrn_name;
+ args->host_if_name = format (0, "%s", ifr.ifr_ifrn.ifrn_name);
unsigned int offload = 0;
hdrsz = sizeof (struct virtio_net_hdr_v1);
@@ -546,6 +546,10 @@ tap_delete_if (vlib_main_t * vm, u32 sw_if_index)
vec_free (vif->rxq_vrings);
vec_free (vif->txq_vrings);
+ vec_free (vif->host_if_name);
+ vec_free (vif->net_ns);
+ vec_free (vif->host_bridge);
+
tm->tap_ids = clib_bitmap_set (tm->tap_ids, vif->id, 0);
clib_memset (vif, 0, sizeof (*vif));
pool_put (mm->interfaces, vif);