DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: clean up per-socket mutex
@ 2017-06-12 21:29 Daniel Verkamp
  2017-06-14  8:19 ` Jens Freimann
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Verkamp @ 2017-06-12 21:29 UTC (permalink / raw)
  To: dev; +Cc: Daniel Verkamp

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);
 			free(vsocket->path);
 			free(vsocket);
 
-- 
2.9.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-01 23:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 21:29 [dpdk-dev] [PATCH] vhost: clean up per-socket mutex Daniel Verkamp
2017-06-14  8:19 ` Jens Freimann
2017-07-01 23:25   ` Yuanhan Liu

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).