From patchwork Thu Oct 14 02:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 101518 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA9E0A0C4B; Thu, 14 Oct 2021 04:12:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56EEF40042; Thu, 14 Oct 2021 04:12:42 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id C59D840041; Thu, 14 Oct 2021 04:12:40 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10136"; a="214739368" X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="214739368" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 19:12:25 -0700 X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="491732282" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 19:12:23 -0700 From: dapengx.yu@intel.com To: Jasvinder Singh , Cristian Dumitrescu Cc: dev@dpdk.org, Dapeng Yu , stable@dpdk.org Date: Thu, 14 Oct 2021 10:12:07 +0800 Message-Id: <20211014021208.361162-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210930083444.636152-1-dapengx.yu@intel.com> References: <20210930083444.636152-1-dapengx.yu@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] net/softnic: fix memory leak of meter policy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dapeng Yu After the meter policies are created, they are not freed on device close. This patch fixes it. Fixes: 5f0d54f372f0 ("ethdev: add pre-defined meter policy API") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu Acked-by: Jasvinder Singh --- V2: * Rebase on top of main branch --- drivers/net/softnic/rte_eth_softnic_meter.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c index 5831892a39..6b02f43e31 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -52,6 +52,18 @@ softnic_mtr_free(struct pmd_internals *p) TAILQ_REMOVE(&p->mtr.meter_profiles, mp, node); free(mp); } + + /* Remove meter policies */ + for ( ; ; ) { + struct softnic_mtr_meter_policy *mp; + + mp = TAILQ_FIRST(&p->mtr.meter_policies); + if (mp == NULL) + break; + + TAILQ_REMOVE(&p->mtr.meter_policies, mp, node); + free(mp); + } } struct softnic_mtr_meter_profile *