From 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 Mon Sep 17 00:00:00 2001 From: Christian Ehrhardt Date: Thu, 4 Jul 2019 10:40:06 +0200 Subject: New upstream version 18.11.2 Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b Signed-off-by: Christian Ehrhardt --- drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers/net/virtio/virtio_user/vhost_kernel_tap.c') diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c index a3faf1d0..fbd9e979 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c @@ -62,6 +62,7 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, const char *mac, uint64_t features) { unsigned int tap_features; + char *tap_name = NULL; int sndbuf = INT_MAX; struct ifreq ifr; int tapfd; @@ -112,6 +113,12 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, goto error; } + tap_name = strdup(ifr.ifr_name); + if (!tap_name) { + PMD_DRV_LOG(ERR, "strdup ifname failed: %s", strerror(errno)); + goto error; + } + fcntl(tapfd, F_SETFL, O_NONBLOCK); if (ioctl(tapfd, TUNSETVNETHDRSZ, &hdr_size) < 0) { @@ -134,11 +141,12 @@ vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, goto error; } - if (!(*p_ifname)) - *p_ifname = strdup(ifr.ifr_name); + free(*p_ifname); + *p_ifname = tap_name; return tapfd; error: + free(tap_name); close(tapfd); return -1; } -- cgit 1.2.3-korg