From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Freimann Subject: [PATCH 1/3] vhost: add missing check strdup() return value Date: Tue, 4 Jul 2017 10:50:41 +0200 Message-ID: <20170704085043.3662-2-jfreimann@redhat.com> References: <20170704085043.3662-1-jfreimann@redhat.com> Cc: yuanhan.liu@linux.intel.com, maxime.coquelin@redhat.com To: dev@dpdk.org Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id CECD620F for ; Tue, 4 Jul 2017 10:50:51 +0200 (CEST) In-Reply-To: <20170704085043.3662-1-jfreimann@redhat.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jens Freimann Add a check for strdup() return value and fail gracefully if we get a bad return code. Signed-off-by: Jens Freimann --- lib/librte_vhost/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 9720773..42b25d3 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; -- 2.9.4