DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Jens Freimann <jfreiman@redhat.com>
Cc: Daniel Verkamp <daniel.verkamp@intel.com>,
	dev@dpdk.org, "Maxime Coquelin (mcoqueli)" <mcoqueli@redhat.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: clean up per-socket mutex
Date: Sun, 2 Jul 2017 07:25:05 +0800	[thread overview]
Message-ID: <20170701232505.GD11626@yliu-home> (raw)
In-Reply-To: <20170614081953.iybnhlwqq6o35ybf@dhcp-192-218.str.redhat.com>

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 <daniel.verkamp@intel.com>
> > ---
> >  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

      reply	other threads:[~2017-07-01 23:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 21:29 Daniel Verkamp
2017-06-14  8:19 ` Jens Freimann
2017-07-01 23:25   ` Yuanhan Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170701232505.GD11626@yliu-home \
    --to=yliu@fridaylinux.org \
    --cc=daniel.verkamp@intel.com \
    --cc=dev@dpdk.org \
    --cc=jfreiman@redhat.com \
    --cc=mcoqueli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).