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 0E2A1A0C41; Tue, 7 Sep 2021 05:42:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F13FC410EB; Tue, 7 Sep 2021 05:42:33 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 1660C40DF8 for ; Tue, 7 Sep 2021 05:42:32 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H3WKH72qQzVqXw; Tue, 7 Sep 2021 11:41:39 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Tue, 7 Sep 2021 11:42:29 +0800 Received: from localhost.localdomain (10.69.192.56) by dggema767-chm.china.huawei.com (10.1.198.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Tue, 7 Sep 2021 11:42:29 +0800 From: Huisong Li To: CC: , , , Date: Tue, 7 Sep 2021 11:41:08 +0800 Message-ID: <20210907034108.58763-1-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema767-chm.china.huawei.com (10.1.198.209) X-CFilter-Loop: Reflected Subject: [dpdk-dev] [RFC V1] examples/l3fwd-power: fix memory leak for rte_pci_device 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" Calling rte_eth_dev_close() will release resources of eth device and close it. But rte_pci_device struct isn't released when app exit, which will lead to memory leak. Fixes: 613ce6691c0d ("examples/l3fwd-power: implement proper shutdown") Signed-off-by: Huisong Li --- examples/l3fwd-power/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index aa7b8db44a..6498b5225e 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -2512,6 +2512,8 @@ main(int argc, char **argv) struct lcore_conf *qconf; struct rte_eth_dev_info dev_info; struct rte_eth_txconf *txconf; + struct rte_eth_dev *eth_dev; + struct rte_device *rte_dev; int ret; uint16_t nb_ports; uint16_t queueid; @@ -2910,7 +2912,14 @@ main(int argc, char **argv) RTE_LOG(ERR, L3FWD_POWER, "rte_eth_dev_stop: err=%d, port=%u\n", ret, portid); + /* Retrieve device address in eth device before closing it. */ + eth_dev = &rte_eth_devices[portid]; + rte_dev = eth_dev->device; rte_eth_dev_close(portid); + ret = rte_dev_remove(rte_dev); + if (ret != 0) + RTE_LOG(ERR, L3FWD_POWER, "rte_dev_remove: err=%d, port=%u\n", + ret, portid); } if (app_mode == APP_MODE_EMPTY_POLL) -- 2.33.0