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 53BC6A0524 for ; Tue, 20 Apr 2021 01:56:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4144040685; Tue, 20 Apr 2021 01:56:18 +0200 (CEST) Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by mails.dpdk.org (Postfix) with ESMTP id 976E840685 for ; Tue, 20 Apr 2021 01:56:17 +0200 (CEST) Received: by mail-qt1-f169.google.com with SMTP id o2so14085441qtr.4 for ; Mon, 19 Apr 2021 16:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hGFqaOq2M9fJ1q9YP6vrdNef1Fv6hT1Tf35YHAdGEdA=; b=ImhBJxa6L5zHy1WjpbsW0qPOA0bH76pA5fgoOB1CnlWR5eTsG7hjCg1fvz3NxSaO5u G9oTM6bIbCaa+HYTDj0QpPDf7mXLDqxF55eVGDUAJm8DAosHNquQX9PEH7HevcgpgEgd ScX7SQiI5XzTQNjUj/w0znL7c7LiNCRNcg82U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hGFqaOq2M9fJ1q9YP6vrdNef1Fv6hT1Tf35YHAdGEdA=; b=M/jKUv8da4IYJQIMZJoik0tRxm57DK1FblxA2zgPwrEB3DJ/g83adrjTtOhmveg5Xa +MfMuh9EbTsBZmFPEVA4UWu/DkkcuaEyORKzdM1OXLgjdPUkJe3Rnp9vOlxYPld+IErM Wu3kcqwWA+AyLns2tLZVPVUm2mm4Nky5L16GcsRBiSKU9kaBQgsWFXWqd7UCUV3+1YQR ScfOwdEPwZIPdw0RZFK781ODBvP1tOsihs4W27p6oiivY3uLZopVeLxi8jR8P7JESnmN 6GwUp7OrP8qaPug7TIQrf7JemYVHzGnGtuEMPkceIIXKJZs8/6kmlxc8COS6loGLlD4A xf1w== X-Gm-Message-State: AOAM532TXlqNfa/Vig/g8KAOU72OyRaGlKvDc6QdN+Lfpzod0eGvyi3N HCVvrdxlbLr8lXhOZS/MyoXd0UZ6PDxRHShlqQuVyg== X-Google-Smtp-Source: ABdhPJwwD6Rm/ZVU3YyntCdrMIjulaFMiOlJ1H3uCeiV0gugBATB0DCIlynaxLLoB0LbEwG9xqobok4asK6K579wAWg= X-Received: by 2002:ac8:5e07:: with SMTP id h7mr14381002qtx.225.1618876576889; Mon, 19 Apr 2021 16:56:16 -0700 (PDT) MIME-Version: 1.0 References: <20210419192838.45708-1-ajit.khaparde@broadcom.com> In-Reply-To: <20210419192838.45708-1-ajit.khaparde@broadcom.com> From: Ajit Khaparde Date: Mon, 19 Apr 2021 16:56:00 -0700 Message-ID: To: dpdk-dev Cc: dpdk stable Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000052f7b205c05c137c" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-stable] [PATCH 1/2] net/bnxt: fix resource cleanup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" --00000000000052f7b205c05c137c Content-Type: text/plain; charset="UTF-8" On Mon, Apr 19, 2021 at 12:28 PM Ajit Khaparde wrote: > > Fix resource cleanup in port close. > Once the pointers are freed, set them to NULL. > Make sure access to the pointers is validated before use. > > Fixes: bb81e07323bb ("net/bnxt: support LED on/off") > Fixes: 804e746c7b73 ("net/bnxt: add hardware resource manager init code") > Fixes: 1d0704f4d793 ("net/bnxt: add device configure operation") > Fixes: 698aa7e95325 ("net/bnxt: add code to determine the Tx COS queue") > Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") > Fixes: 0bf5a0b5ebb8 ("net/bnxt: add a failure log") > Cc: stable@dpdk.org > > Signed-off-by: Ajit Khaparde Patch applied to dpdk-next-net-brcm. > --- > drivers/net/bnxt/bnxt_ethdev.c | 39 +++++++++++++++++++++++++--------- > drivers/net/bnxt/bnxt_hwrm.c | 3 +++ > 2 files changed, 32 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c > index 20ca57eae5..dc3b04110f 100644 > --- a/drivers/net/bnxt/bnxt_ethdev.c > +++ b/drivers/net/bnxt/bnxt_ethdev.c > @@ -219,16 +219,19 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) > static void bnxt_free_parent_info(struct bnxt *bp) > { > rte_free(bp->parent); > + bp->parent = NULL; > } > > static void bnxt_free_pf_info(struct bnxt *bp) > { > rte_free(bp->pf); > + bp->pf = NULL; > } > > static void bnxt_free_link_info(struct bnxt *bp) > { > rte_free(bp->link_info); > + bp->link_info = NULL; > } > > static void bnxt_free_leds_info(struct bnxt *bp) > @@ -249,7 +252,9 @@ static void bnxt_free_flow_stats_info(struct bnxt *bp) > static void bnxt_free_cos_queues(struct bnxt *bp) > { > rte_free(bp->rx_cos_queue); > + bp->rx_cos_queue = NULL; > rte_free(bp->tx_cos_queue); > + bp->tx_cos_queue = NULL; > } > > static void bnxt_free_mem(struct bnxt *bp, bool reconfig) > @@ -849,9 +854,14 @@ static int bnxt_shutdown_nic(struct bnxt *bp) > > uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) > { > - uint32_t link_speed = bp->link_info->support_speeds; > + uint32_t link_speed = 0; > uint32_t speed_capa = 0; > > + if (bp->link_info == NULL) > + return 0; > + > + link_speed = bp->link_info->support_speeds; > + > /* If PAM4 is configured, use PAM4 supported speed */ > if (link_speed == 0 && bp->link_info->support_pam4_speeds > 0) > link_speed = bp->link_info->support_pam4_speeds; > @@ -1293,12 +1303,13 @@ static void bnxt_free_switch_domain(struct bnxt *bp) > { > int rc = 0; > > - if (bp->switch_domain_id) { > - rc = rte_eth_switch_domain_free(bp->switch_domain_id); > - if (rc) > - PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", > - bp->switch_domain_id, rc); > - } > + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) > + return; > + > + rc = rte_eth_switch_domain_free(bp->switch_domain_id); > + if (rc) > + PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", > + bp->switch_domain_id, rc); > } > > static void bnxt_ptp_get_current_time(void *arg) > @@ -1545,11 +1556,9 @@ bnxt_uninit_locks(struct bnxt *bp) > > static void bnxt_drv_uninit(struct bnxt *bp) > { > - bnxt_free_switch_domain(bp); > bnxt_free_leds_info(bp); > bnxt_free_cos_queues(bp); > bnxt_free_link_info(bp); > - bnxt_free_pf_info(bp); > bnxt_free_parent_info(bp); > bnxt_uninit_locks(bp); > > @@ -1559,6 +1568,7 @@ static void bnxt_drv_uninit(struct bnxt *bp) > bp->rx_mem_zone = NULL; > > bnxt_free_vf_info(bp); > + bnxt_free_pf_info(bp); > > rte_free(bp->grp_info); > bp->grp_info = NULL; > @@ -1720,6 +1730,10 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) > return rc; > > memset(&new, 0, sizeof(new)); > + > + if (bp->link_info == NULL) > + goto out; > + > do { > /* Retrieve link info from hardware */ > rc = bnxt_get_hwrm_link_config(bp, &new); > @@ -5748,7 +5762,10 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) > bnxt_free_mem(bp, reconfig_dev); > > bnxt_hwrm_func_buf_unrgtr(bp); > - rte_free(bp->pf->vf_req_buf); > + if (bp->pf != NULL) { > + rte_free(bp->pf->vf_req_buf); > + bp->pf->vf_req_buf = NULL; > + } > > rc = bnxt_hwrm_func_driver_unregister(bp, 0); > bp->flags &= ~BNXT_FLAG_REGISTERED; > @@ -5761,6 +5778,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) > bnxt_uninit_ctx_mem(bp); > > bnxt_free_flow_stats_info(bp); > + if (bp->rep_info != NULL) > + bnxt_free_switch_domain(bp); > bnxt_free_rep_info(bp); > rte_free(bp->ptp_cfg); > bp->ptp_cfg = NULL; > diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c > index a119fc3a0b..242493982c 100644 > --- a/drivers/net/bnxt/bnxt_hwrm.c > +++ b/drivers/net/bnxt/bnxt_hwrm.c > @@ -795,6 +795,9 @@ void bnxt_free_vf_info(struct bnxt *bp) > if (bp->pf->vf_info == NULL) > return; > > + if (bp->pf == NULL) > + return; > + > for (i = 0; i < bp->pf->max_vfs; i++) { > rte_free(bp->pf->vf_info[i].vlan_table); > bp->pf->vf_info[i].vlan_table = NULL; > -- > 2.21.1 (Apple Git-122.3) > --00000000000052f7b205c05c137c--