From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <hvemulax@ecsmtp.ir.intel.com>
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 615FA5B2C;
 Wed, 14 Nov 2018 12:20:03 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga006.fm.intel.com ([10.253.24.20])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 14 Nov 2018 03:20:02 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.56,232,1539673200"; d="scan'208";a="280988045"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by fmsmga006.fm.intel.com with ESMTP; 14 Nov 2018 03:20:01 -0800
Received: from wgcvswdev002.ir.intel.com (wgcvswdev002.ir.intel.com
 [10.102.246.106])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 wAEBK0wC010566; Wed, 14 Nov 2018 11:20:00 GMT
Received: from wgcvswdev002.ir.intel.com (localhost [127.0.0.1])
 by wgcvswdev002.ir.intel.com with ESMTP id wAEBI6UD016215;
 Wed, 14 Nov 2018 11:18:06 GMT
Received: (from hvemulax@localhost)
	by wgcvswdev002.ir.intel.com with œ id wAEBI6pt016211;
	Wed, 14 Nov 2018 11:18:06 GMT
From: Hari Kumar Vemula <hari.kumarx.vemula@intel.com>
To: dev@dpdk.org
Cc: byron.marohn@intel.com, reshma.pattan@intel.com,
 pablo.de.lara.guarch@intel.com,
 Hari Kumar Vemula <hari.kumarx.vemula@intel.com>, stable@dpdk.org
Date: Wed, 14 Nov 2018 11:17:45 +0000
Message-Id: <1542194265-16156-1-git-send-email-hari.kumarx.vemula@intel.com>
X-Mailer: git-send-email 1.7.0.7
In-Reply-To: <1542109533-14283-1-git-send-email-hari.kumarx.vemula@intel.com>
References: <1542109533-14283-1-git-send-email-hari.kumarx.vemula@intel.com>
Subject: [dpdk-stable] [PATCH v2] lib/efd: fix to free tail queue entry
	after use
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Nov 2018 11:20:04 -0000

In rte_efd_create() allocated memory for tail queue entry but
not freed.
Added freeing the tail queue entry.

Fixes: 56b6ef874f80 ("efd: new Elastic Flow Distributor library")
Cc: stable@dpdk.org

Signed-off-by: Hari Kumar Vemula <hari.kumarx.vemula@intel.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>

---
v2: Updated commit message.
---

 lib/librte_efd/rte_efd.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/librte_efd/rte_efd.c b/lib/librte_efd/rte_efd.c
index a780e2fe8..f8c6c447f 100644
--- a/lib/librte_efd/rte_efd.c
+++ b/lib/librte_efd/rte_efd.c
@@ -739,17 +739,38 @@ void
 rte_efd_free(struct rte_efd_table *table)
 {
 	uint8_t socket_id;
+	struct rte_efd_list *efd_list = NULL;
+	struct rte_tailq_entry *te;
 
 	if (table == NULL)
 		return;
 
+	efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list);
+
 	for (socket_id = 0; socket_id < RTE_MAX_NUMA_NODES; socket_id++)
 		rte_free(table->chunks[socket_id]);
 
+	rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
+
+	/* find our tailq entry */
+	TAILQ_FOREACH(te, efd_list, next) {
+		if (te->data == (void *) table)
+			break;
+	}
+
+	if (te == NULL) {
+		rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+		return;
+	}
+
+	TAILQ_REMOVE(efd_list, te, next);
+	rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
+
 	rte_ring_free(table->free_slots);
 	rte_free(table->offline_chunks);
 	rte_free(table->keys);
 	rte_free(table);
+	rte_free(te);
 }
 
 /**
-- 
2.13.6