diff options
author | Ricardo Salveti <ricardo.salveti@linaro.org> | 2016-07-18 15:30:06 -0300 |
---|---|---|
committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-07-19 08:26:18 +0200 |
commit | 8be94df6e9f5f70516cb86d82dd04fefaa0fe8b3 (patch) | |
tree | b055d508e145ddc35943c4a083aa846855c92732 /lib/librte_vhost/vhost_user/vhost-net-user.c | |
parent | ddb3f4884bd4cdb8659fb8326c27986a5c832ade (diff) |
Imported Upstream version 16.07-rc2
Change-Id: Ie9e8ec528a2a0dace085c5e44aa7fa3b489d4ba0
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'lib/librte_vhost/vhost_user/vhost-net-user.c')
-rw-r--r-- | lib/librte_vhost/vhost_user/vhost-net-user.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c index 94f1b923..a0d83f3c 100644 --- a/lib/librte_vhost/vhost_user/vhost-net-user.c +++ b/lib/librte_vhost/vhost_user/vhost-net-user.c @@ -439,6 +439,7 @@ create_unix_socket(const char *path, struct sockaddr_un *un, bool is_server) memset(un, 0, sizeof(*un)); un->sun_family = AF_UNIX; strncpy(un->sun_path, path, sizeof(un->sun_path)); + un->sun_path[sizeof(un->sun_path) - 1] = '\0'; return fd; } @@ -576,6 +577,12 @@ vhost_user_create_client(struct vhost_user_socket *vsocket) RTE_LOG(ERR, VHOST_CONFIG, "%s: reconnecting...\n", path); reconn = malloc(sizeof(*reconn)); + if (reconn == NULL) { + RTE_LOG(ERR, VHOST_CONFIG, + "failed to allocate memory for reconnect\n"); + close(fd); + return -1; + } reconn->un = un; reconn->fd = fd; reconn->vsocket = vsocket; @@ -617,8 +624,11 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); if (vsocket->reconnect && reconn_tid == 0) { - if (vhost_user_reconnect_init() < 0) + if (vhost_user_reconnect_init() < 0) { + free(vsocket->path); + free(vsocket); goto out; + } } ret = vhost_user_create_client(vsocket); } else { |