From 532f2ea5f8e208aa48645be2fd5f1c8b495ec786 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Tue, 28 Jun 2016 11:58:29 +0800 Subject: [PATCH] vhost: fix memory leak Fix potential memory leak raised by Coverity. >>> Variable "vsocket" going out of scope leaks the storage it >>> points to. Coverity issue: 127483 Fixes: e623e0c6d8a5 ("vhost: add reconnect ability") Reported-by: John McNamara Signed-off-by: Yuanhan Liu --- lib/librte_vhost/vhost_user/vhost-net-user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c index 94f1b92393..90cc127612 100644 --- a/lib/librte_vhost/vhost_user/vhost-net-user.c +++ b/lib/librte_vhost/vhost_user/vhost-net-user.c @@ -617,8 +617,11 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); if (vsocket->reconnect && reconn_tid == 0) { - if (vhost_user_reconnect_init() < 0) + if (vhost_user_reconnect_init() < 0) { + free(vsocket->path); + free(vsocket); goto out; + } } ret = vhost_user_create_client(vsocket); } else { -- 2.20.1