From patchwork Mon Jun 17 15:05:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 54847 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 466891BEF6; Mon, 17 Jun 2019 17:05:52 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 2F5A92BE6 for ; Mon, 17 Jun 2019 17:05:51 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27C36356E8; Mon, 17 Jun 2019 15:05:46 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D760E5944E; Mon, 17 Jun 2019 15:05:40 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, Rastislav Cernay , Jan Remes Date: Mon, 17 Jun 2019 17:05:22 +0200 Message-Id: <1560783924-5355-2-git-send-email-david.marchand@redhat.com> In-Reply-To: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> References: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Jun 2019 15:05:48 +0000 (UTC) Subject: [dpdk-dev] [PATCH 1/3] net/nfb: avoid memory leak on unplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Clearing mac_addrs on remove will prevent ethdev from freeing it. Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver") Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- drivers/net/nfb/nfb_ethdev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c index fdd0e70..6f77864 100644 --- a/drivers/net/nfb/nfb_ethdev.c +++ b/drivers/net/nfb/nfb_ethdev.c @@ -510,8 +510,6 @@ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_pci_addr *pci_addr = &pci_dev->addr; - dev->data->mac_addrs = NULL; - nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac); nfb_nc_txmac_deinit(internals->txmac, internals->max_txmac); From patchwork Mon Jun 17 15:05:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 54848 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 267891BF3E; Mon, 17 Jun 2019 17:06:01 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 680B22BE6; Mon, 17 Jun 2019 17:05:59 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2313530C084B; Mon, 17 Jun 2019 15:05:50 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98A335F5A4; Mon, 17 Jun 2019 15:05:46 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, stable@dpdk.org, Rasesh Mody , Shahed Shaikh Date: Mon, 17 Jun 2019 17:05:23 +0200 Message-Id: <1560783924-5355-3-git-send-email-david.marchand@redhat.com> In-Reply-To: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> References: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 17 Jun 2019 15:05:55 +0000 (UTC) Subject: [dpdk-dev] [PATCH 2/3] net/bnx2x: fix invalid free on unplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" mac_addrs points to a field in dev_private. We can't let ethdev free it. Fixes: e16adf08e54d ("ethdev: free all common data when releasing port") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- drivers/net/bnx2x/bnx2x_ethdev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index 45c6c36..f47a73c 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -701,6 +701,13 @@ void bnx2x_periodic_stop(void *param) return bnx2x_common_dev_init(eth_dev, 1); } +static int eth_bnx2x_dev_uninit(struct rte_eth_dev *eth_dev) +{ + /* mac_addrs must not be freed alone because part of dev_private */ + eth_dev->data->mac_addrs = NULL; + return 0; +} + static struct rte_pci_driver rte_bnx2x_pmd; static struct rte_pci_driver rte_bnx2xvf_pmd; @@ -719,7 +726,7 @@ static int eth_bnx2x_pci_probe(struct rte_pci_driver *pci_drv, static int eth_bnx2x_pci_remove(struct rte_pci_device *pci_dev) { - return rte_eth_dev_pci_generic_remove(pci_dev, NULL); + return rte_eth_dev_pci_generic_remove(pci_dev, eth_bnx2x_dev_uninit); } static struct rte_pci_driver rte_bnx2x_pmd = { From patchwork Mon Jun 17 15:05:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 54849 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D7DE1BF4C; Mon, 17 Jun 2019 17:06:17 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id CCFA41BF45; Mon, 17 Jun 2019 17:06:14 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29815821CB; Mon, 17 Jun 2019 15:05:59 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D900A68C62; Mon, 17 Jun 2019 15:05:50 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, stable@dpdk.org, Shepard Siegel , Ed Czeck , John Miller , Ravi Kumar , Beilei Xing , Qi Zhang , Qiming Yang , Wenzhuo Lu , Jerin Jacob , Maciej Czekaj Date: Mon, 17 Jun 2019 17:05:24 +0200 Message-Id: <1560783924-5355-4-git-send-email-david.marchand@redhat.com> In-Reply-To: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> References: <1560783924-5355-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Jun 2019 15:06:14 +0000 (UTC) Subject: [dpdk-dev] [PATCH 3/3] drivers/net: fix double free on init failure cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" If we don't clear mac_addrs, ethdev will double free it on cleanup. Fixes: e16adf08e54d ("ethdev: free all common data when releasing port") Cc: stable@dpdk.org Signed-off-by: David Marchand Reviewed-by: Ferruh Yigit --- drivers/net/ark/ark_ethdev.c | 6 +++--- drivers/net/axgbe/axgbe_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/ice/ice_ethdev.c | 1 + drivers/net/thunderx/nicvf_ethdev.c | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 7fd784c..86e500e 100644 --- a/drivers/net/ark/ark_ethdev.c +++ b/drivers/net/ark/ark_ethdev.c @@ -403,9 +403,9 @@ static void eth_ark_macaddr_remove(struct rte_eth_dev *dev, return ret; - error: - if (dev->data->mac_addrs) - rte_free(dev->data->mac_addrs); +error: + rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = NULL; return -1; } diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 6b3bc3e..cfb1720 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -700,6 +700,7 @@ static void axgbe_default_config(struct axgbe_port *pdata) ret = pdata->phy_if.phy_init(pdata); if (ret) { rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; return ret; } diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 3cf2c1b..69a9cff 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1600,6 +1600,7 @@ static inline void i40e_config_automask(struct i40e_pf *pf) rte_free(pf->ethertype.hash_map); err_init_ethtype_filter_list: rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = NULL; err_mac_alloc: i40e_vsi_release(pf->main_vsi); err_setup_pf_switch: diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index bdbceb4..a7de455 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1466,6 +1466,7 @@ static int ice_load_pkg(struct rte_eth_dev *dev) ice_res_pool_destroy(&pf->msix_pool); err_msix_pool_init: rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = NULL; err_init_mac: ice_sched_cleanup_all(hw); rte_free(hw->port_info); diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index eb2c11d..ec57692 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -2206,6 +2206,7 @@ static void nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, malloc_fail: rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; alarm_fail: nicvf_periodic_alarm_stop(nicvf_interrupt, eth_dev); fail: