From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 45DDF5587 for ; Tue, 4 Jul 2017 10:50:57 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 860883B703; Tue, 4 Jul 2017 08:50:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 860883B703 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfreimann@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 860883B703 Received: from localhost (dhcp-192-218.str.redhat.com [10.33.192.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 763F66BF8C; Tue, 4 Jul 2017 08:50:54 +0000 (UTC) From: Jens Freimann To: dev@dpdk.org Cc: yuanhan.liu@linux.intel.com, maxime.coquelin@redhat.com Date: Tue, 4 Jul 2017 10:50:43 +0200 Message-Id: <20170704085043.3662-4-jfreimann@redhat.com> In-Reply-To: <20170704085043.3662-1-jfreimann@redhat.com> References: <20170704085043.3662-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 04 Jul 2017 08:50:56 +0000 (UTC) Subject: [dpdk-dev] [PATCH 3/3] vhost: check return value of pthread_mutex_init() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jul 2017 08:50:57 -0000 Check return value of pthread_mutex_init(). Also destroy mutex in case of other erros before returning. Signed-off-by: Jens Freimann --- lib/librte_vhost/socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 7b5df6f..83ef943 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -445,13 +445,21 @@ vhost_user_reconnect_init(void) { int ret; - pthread_mutex_init(&reconn_list.mutex, NULL); + ret = pthread_mutex_init(&reconn_list.mutex, NULL); + if (ret < 0) { + RTE_LOG(ERR, VHOST_CONFIG, "failed to initialize mutex"); + return ret; + } TAILQ_INIT(&reconn_list.head); ret = pthread_create(&reconn_tid, NULL, vhost_user_client_reconnect, NULL); - if (ret < 0) + if (ret < 0) { RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread"); + if (pthread_mutex_destroy(&reconn_list.mutex)) + RTE_LOG(ERR, VHOST_CONFIG, + "failed to destroy reconnect mutex"); + } return ret; } -- 2.9.4