]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bnxt_en: Free bp->ctx inside bnxt_free_ctx_mem()
authorMichael Chan <michael.chan@broadcom.com>
Mon, 20 Nov 2023 23:43:54 +0000 (15:43 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 22 Nov 2023 01:32:47 +0000 (17:32 -0800)
We always free bp->ctx right after calling bnxt_free_ctx_mem(), so just
free it at the end of that function to make things simpler.

Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20231120234405.194542-3-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

index 6b19d5b8d95a8d6c0e7ad8744b624d694aab585e..8ff21768e5927f2dbd5a50e38985440cd9281f09 100644 (file)
@@ -7552,6 +7552,8 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
        bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem);
        bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem);
        ctx->flags &= ~BNXT_CTX_FLAG_INITED;
+       kfree(ctx);
+       bp->ctx = NULL;
 }
 
 static int bnxt_alloc_ctx_mem(struct bnxt *bp)
@@ -10321,8 +10323,6 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
                        if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
                                bnxt_ulp_stop(bp);
                        bnxt_free_ctx_mem(bp);
-                       kfree(bp->ctx);
-                       bp->ctx = NULL;
                        bnxt_dcb_free(bp);
                        rc = bnxt_fw_init_one(bp);
                        if (rc) {
@@ -11948,8 +11948,6 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
        if (pci_is_enabled(bp->pdev))
                pci_disable_device(bp->pdev);
        bnxt_free_ctx_mem(bp);
-       kfree(bp->ctx);
-       bp->ctx = NULL;
 }
 
 static bool is_bnxt_fw_ok(struct bnxt *bp)
@@ -13368,8 +13366,6 @@ static void bnxt_remove_one(struct pci_dev *pdev)
        bp->fw_health = NULL;
        bnxt_cleanup_pci(bp);
        bnxt_free_ctx_mem(bp);
-       kfree(bp->ctx);
-       bp->ctx = NULL;
        kfree(bp->rss_indir_tbl);
        bp->rss_indir_tbl = NULL;
        bnxt_free_port_stats(bp);
@@ -13969,8 +13965,6 @@ init_err_pci_clean:
        bp->fw_health = NULL;
        bnxt_cleanup_pci(bp);
        bnxt_free_ctx_mem(bp);
-       kfree(bp->ctx);
-       bp->ctx = NULL;
        kfree(bp->rss_indir_tbl);
        bp->rss_indir_tbl = NULL;
 
@@ -14023,8 +14017,6 @@ static int bnxt_suspend(struct device *device)
        bnxt_hwrm_func_drv_unrgtr(bp);
        pci_disable_device(bp->pdev);
        bnxt_free_ctx_mem(bp);
-       kfree(bp->ctx);
-       bp->ctx = NULL;
        rtnl_unlock();
        return rc;
 }
@@ -14121,8 +14113,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
        if (pci_is_enabled(pdev))
                pci_disable_device(pdev);
        bnxt_free_ctx_mem(bp);
-       kfree(bp->ctx);
-       bp->ctx = NULL;
        rtnl_unlock();
 
        /* Request a slot slot reset. */
index f302dac565996d11f7d6f1f35d8100fd6aad9896..10b842539b08fc441e657b0eaca41191d332f346 100644 (file)
@@ -469,8 +469,6 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,
                }
                bnxt_cancel_reservations(bp, false);
                bnxt_free_ctx_mem(bp);
-               kfree(bp->ctx);
-               bp->ctx = NULL;
                break;
        }
        case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: {