From 3a70fc0d47a8ea0fa291093506f5bb2584804640 Mon Sep 17 00:00:00 2001 From: wuzhouhui Date: Wed, 22 Aug 2018 13:59:16 +0800 Subject: [PATCH] rte_vhost:rte_vhost_driver_register(): check if strdup succeeds Change-Id: I95e10ca3f7a8e212b46a9c5a62d18cbf2b1fff45 Signed-off-by: wuzhouhui Reviewed-on: https://review.gerrithub.io/423046 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System --- lib/vhost/rte_vhost/socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vhost/rte_vhost/socket.c b/lib/vhost/rte_vhost/socket.c index 92df4de731..1bc1e64ba3 100644 --- a/lib/vhost/rte_vhost/socket.c +++ b/lib/vhost/rte_vhost/socket.c @@ -635,6 +635,10 @@ 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) { + 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;