From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E596FA034F; Tue, 1 Mar 2022 03:11:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 796A74067B; Tue, 1 Mar 2022 03:11:32 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id D1A6640151 for ; Tue, 1 Mar 2022 03:11:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646100691; x=1677636691; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tX1zmPK+bvGT4DGb2+BjZVvxeL1zOIpp7mmXHO6RGuI=; b=ESYyXHvBwZ13Hc90Ay7gHJt+Pm4ess1ubjQMtFzZaRQJtj/YX+9tak4+ 5Qj0QvfW8S9VzlAUr0RPuQxvlDebAx7TToK8IXA2TS320q3Ikm3asGXCS wAR4VISZrekmbHWurpj2cSlDvPHWhTynYTIFQfzIOVMVeW4BzsQT6c3QD GTRD9PY19GdOrcg0C+ssVCmNz7cnWG1qkGThG/TJv2CE/6KFLLqaSe1GG oCs4s+eUX8nJJoVRQjfOHCjKnHo71K4USBv3kDo3ZbQHXSCUoKCYynZ8q 6zCo0jxeKV/vKz7bMXUrb7bKkoTJmHJI4iWnLGs0SG+TsNXcjgeobCqKz g==; X-IronPort-AV: E=McAfee;i="6200,9189,10272"; a="277699311" X-IronPort-AV: E=Sophos;i="5.90,144,1643702400"; d="scan'208";a="277699311" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 18:11:29 -0800 X-IronPort-AV: E=Sophos;i="5.90,144,1643702400"; d="scan'208";a="685553308" Received: from intel-corei7-64.sh.intel.com (HELO localhost.localdomain) ([10.239.251.104]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 18:11:27 -0800 From: Ke Zhang To: xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, dev@dpdk.org Cc: Ke Zhang Subject: [PATCH] app/testpmd: fix issue with memory leaks when quit testpmd Date: Tue, 1 Mar 2022 02:06:53 +0000 Message-Id: <20220301020653.329263-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 when dpdk is compiled in ASan, there is a memory leaks after quit testpmd if set mcast_addr, this patch fix this issue. Error info as following: ERROR: LeakSanitizer: detected memory leaksDirect leak of 192 byte(s) 0 0x7f6a2e0aeffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) 1 0x565361eb340f in mcast_addr_pool_extend ../app/test-pmd/config.c:5162 2 0x565361eb3556 in mcast_addr_pool_append ../app/test-pmd/config.c:5180 3 0x565361eb3aae in mcast_addr_add ../app/test-pmd/config.c:5243 Signed-off-by: Ke Zhang --- app/test-pmd/testpmd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..fa7f80fdf7 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2742,6 +2742,8 @@ start_port(portid_t pid) continue; } + port->mc_addr_pool = NULL; + if (port->need_reconfig > 0) { struct rte_eth_conf dev_conf; int k; @@ -3065,6 +3067,16 @@ stop_port(portid_t pid) if (eth_dev_stop_mp(pi) != 0) RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", pi); + /* + * free the pool of multicast addresses. If it is NULL, + * it means there is no mc addr.Make sure the mc_addr_pool + * is NULL at port init. + */ + if (port->mc_addr_pool != NULL) { + free(port->mc_addr_pool); + port->mc_addr_pool = NULL; + } + port->mc_addr_nb = 0; if (port->port_status == RTE_PORT_HANDLING) port->port_status = RTE_PORT_STOPPED; -- 2.25.1