From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A537711A2 for ; Tue, 28 Jun 2016 05:58:23 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 27 Jun 2016 20:58:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,539,1459839600"; d="scan'208";a="836360680" Received: from unknown (HELO yliu-dev.sh.intel.com) ([10.239.67.162]) by orsmga003.jf.intel.com with ESMTP; 27 Jun 2016 20:58:21 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, John McNamara , Yuanhan Liu Date: Tue, 28 Jun 2016 11:58:29 +0800 Message-Id: <1467086311-13527-2-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1467086311-13527-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1467086311-13527-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 1/3] vhost: fix memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2016 03:58:24 -0000 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 94f1b92..90cc127 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 { -- 1.9.0