From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 1052B2B99 for ; Sun, 2 Jul 2017 01:25:12 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id c24so6792184pfe.1 for ; Sat, 01 Jul 2017 16:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=M1otCpEkn7VvwJHnhzuy6T43eBo8BF9kJ72QvbGTmU4=; b=hWOO8s0No+bgRe6tZ8YJ0NaSLqXu1ebfGHbVvGQr+l6UfmKoHyaPDVoLfw5baTvqjD +RhjCY5Xc/4TIQbsUnh4MVrE96VlesDj4zwvMVIwzeVcEw8yOTnKnVBKHkh6e/N9eo1y Tw3LnjsUbnsnQUEn7HARW9/kM+7Sl9E7t9PsI6pSSVVy5TLZdgunaVFIIAXYChlrmszT jSiQ+BD9cApfxeWJL4YRTMwm1pm9UI73+6qjd1/U29au4MV4D5rbVuFhJKs+o578ZyNH Z/kgqZqi0TRR6cWxJdBMS6QFv45co1VJ0wr3ux465SyRWnWiQKUa91Rq1Pe8yDX79piy 0jbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=M1otCpEkn7VvwJHnhzuy6T43eBo8BF9kJ72QvbGTmU4=; b=H+YsaTB0mZtJv3xIhLRFPSoRCo1rlbbN5ta24s9wzn3xW0unJDHWLi2p8k+zrsyOkT yUrNq1u30NijuG1NR5ghXEWW+Wy8Ro9BqBYCckp+uwpzUK6vh1GQCewADeAkv4jONFRg yfdCvmRBVvAHAkqwhc7OBGgXDO+Nx6vk4dU4r1oIsEzzxSgtyS1Ucp73ZQjCShOdRR7I JcbrG2H91lxv0sGN9LRZfkttRf312yiq5dnRFK05kVQqBYqx2NgPPUhuZ4kdSBNIYQ7n AUvbEBhtZe+ygmmE6Y8PZqfdG5T/sWK2KXFhI5fwPXMylD4Wdg5V9zsIPnIWI+YsE7iw Y8iA== X-Gm-Message-State: AIVw111mR07lcuwSU1Ln8RXidUGZXfNARYQLnl8msDql+R7OYCFdqOdA sbFabxfJxO0FMGJa X-Received: by 10.99.5.82 with SMTP id 79mr2702690pgf.134.1498951512218; Sat, 01 Jul 2017 16:25:12 -0700 (PDT) Received: from yliu-home ([45.63.61.64]) by smtp.gmail.com with ESMTPSA id i186sm20491743pgd.55.2017.07.01.16.25.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Jul 2017 16:25:11 -0700 (PDT) Date: Sun, 2 Jul 2017 07:25:05 +0800 From: Yuanhan Liu To: Jens Freimann Cc: Daniel Verkamp , dev@dpdk.org, "Maxime Coquelin (mcoqueli)" Message-ID: <20170701232505.GD11626@yliu-home> References: <20170612212904.8787-1-daniel.verkamp@intel.com> <20170614081953.iybnhlwqq6o35ybf@dhcp-192-218.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170614081953.iybnhlwqq6o35ybf@dhcp-192-218.str.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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: Sat, 01 Jul 2017 23:25:13 -0000 On Wed, Jun 14, 2017 at 10:19:53AM +0200, Jens Freimann wrote: > 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? I think so. There are more: pthread_mutex_init/lock, etc. We probably should make another patch to fix it. For this patch, I'd like to apply as it is. So applied to dpdk-next-virtio. Thanks. --yliu