From: Jens Freimann Date: Tue, 4 Jul 2017 08:50:41 +0000 (+0200) Subject: vhost: add missing check in driver registration X-Git-Tag: spdx-start~2708 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6846128798741f70555a6ca10133458c5491cf12;p=dpdk.git vhost: add missing check in driver registration Add a check for strdup() return value and fail gracefully if we get a bad return code. Signed-off-by: Jens Freimann Acked-by: Yuanhan Liu --- diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 9720773853..42b25d3480 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -613,6 +613,12 @@ rte_vhost_driver_register(const char *path, uint64_t flags) goto out; memset(vsocket, 0, sizeof(struct vhost_user_socket)); vsocket->path = strdup(path); + if (vsocket->path == NULL) { + RTE_LOG(ERR, VHOST_CONFIG, + "error: failed to copy socket path string\n"); + free(vsocket); + goto out; + } TAILQ_INIT(&vsocket->conn_list); pthread_mutex_init(&vsocket->conn_mutex, NULL); vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;