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 7C6637CBE for ; Wed, 14 Jun 2017 10:19:56 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7374F80472; Wed, 14 Jun 2017 08:19:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7374F80472 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfreiman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7374F80472 Received: from localhost (dhcp-192-218.str.redhat.com [10.33.192.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 047E9972FB; Wed, 14 Jun 2017 08:19:54 +0000 (UTC) Date: Wed, 14 Jun 2017 10:19:53 +0200 From: Jens Freimann To: Daniel Verkamp Cc: dev@dpdk.org, "Maxime Coquelin (mcoqueli)" , Yuanhan Liu Message-ID: <20170614081953.iybnhlwqq6o35ybf@dhcp-192-218.str.redhat.com> References: <20170612212904.8787-1-daniel.verkamp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170612212904.8787-1-daniel.verkamp@intel.com> User-Agent: NeoMutt/20170602 (1.8.3) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Jun 2017 08:19:55 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH] vhost: clean up per-socket mutex 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: Wed, 14 Jun 2017 08:19:56 -0000 On Mon, Jun 12, 2017 at 02:29:04PM -0700, Daniel Verkamp wrote: > vsocket->conn_mutex was allocated with pthread_mutex_init() but never > freed with pthread_mutex_destroy(). This is a potential memory leak, > depending on how pthread_mutex_t is implemented. > > Signed-off-by: Daniel Verkamp > --- > lib/librte_vhost/socket.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c > index c7f99b0..9720773 100644 > --- a/lib/librte_vhost/socket.c > +++ b/lib/librte_vhost/socket.c > @@ -636,6 +636,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) > vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); > if (vsocket->reconnect && reconn_tid == 0) { > if (vhost_user_reconnect_init() < 0) { > + pthread_mutex_destroy(&vsocket->conn_mutex); > free(vsocket->path); > free(vsocket); > goto out; > @@ -646,6 +647,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) > } > ret = create_unix_socket(vsocket); > if (ret < 0) { > + pthread_mutex_destroy(&vsocket->conn_mutex); > free(vsocket->path); > free(vsocket); > goto out; > @@ -724,6 +726,7 @@ rte_vhost_driver_unregister(const char *path) > } > pthread_mutex_unlock(&vsocket->conn_mutex); > > + pthread_mutex_destroy(&vsocket->conn_mutex); Seems like we never do it, but shouldn't we check the return value here? regards, Jens