diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index 86cce6f53f78..c365d3cf8e51 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c @@ -468,11 +468,11 @@ int bnxt_dl_register(struct bnxt *bp) return -ENOMEM; } - bnxt_link_bp_to_dl(dl, bp); + bnxt_link_bp_to_dl(bp, dl); bp->eswitch_mode = DEVLINK_ESWITCH_MODE_LEGACY; rc = devlink_register(dl, &bp->pdev->dev); if (rc) { - bnxt_link_bp_to_dl(dl, NULL); + bnxt_link_bp_to_dl(bp, NULL); devlink_free(dl); netdev_warn(bp->dev, "devlink_register failed. rc=%d", rc); return rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h index e55a3b693e20..3e997c9e2580 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h @@ -24,13 +24,17 @@ static inline struct bnxt *bnxt_get_bp_from_dl(struct devlink *dl) return ((struct bnxt_dl *)devlink_priv(dl))->bp; } -static inline void bnxt_link_bp_to_dl(struct devlink *dl, struct bnxt *bp) +/* To clear devlink pointer from bp, pass NULL dl */ +static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl) { - struct bnxt_dl *bp_dl = devlink_priv(dl); + bp->dl = dl; - bp_dl->bp = bp; - if (bp) - bp->dl = dl; + /* add a back pointer in dl to bp */ + if (dl) { + struct bnxt_dl *bp_dl = devlink_priv(dl); + + bp_dl->bp = bp; + } } int bnxt_dl_register(struct bnxt *bp);