Skip to content

Commit

Permalink
bnxt_en: fix clearing devlink ptr from bnxt struct
Browse files Browse the repository at this point in the history
The routine bnxt_link_bp_to_dl() is used to set the devlink ptr
in bnxt struct (bp) and also to set the bnxt back ptr in
the devlink struct.  If devlink_register() fails, bp->dl must
be cleared which is not happening currently. This patch fixes
bnxt_link_bp_to_dl() to clear bp->dl by passing  a NULL dl ptr.

Fixes: 4ab0c6a ("bnxt_en: add support to enable VF-representors")
Signed-off-by: Sathya Perla <[email protected]>
Signed-off-by: Michael Chan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Sathya Perla authored and davem330 committed Aug 28, 2017
1 parent d5430d3 commit 7085560
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7085560

Please sign in to comment.