Skip to content

Commit

Permalink
bnxt_en: fix memory leak in bnxt_nvm_test()
Browse files Browse the repository at this point in the history
Free the kzalloc'ed buffer before returning in the success path.

Fixes: 5b6ff12 ("bnxt_en: implement callbacks for devlink selftests")
Signed-off-by: Vikas Gupta <[email protected]>
Signed-off-by: Michael Chan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
vikasbrcm authored and kuba-moo committed Oct 19, 2022
1 parent 1ca6952 commit ba077d6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti

static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack)
{
bool rc = false;
u32 datalen;
u16 index;
u8 *buf;
Expand All @@ -632,20 +633,20 @@ static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack)

if (bnxt_get_nvram_item(bp->dev, index, 0, datalen, buf)) {
NL_SET_ERR_MSG_MOD(extack, "nvm test vpd read error");
goto err;
goto done;
}

if (bnxt_flash_nvram(bp->dev, BNX_DIR_TYPE_VPD, BNX_DIR_ORDINAL_FIRST,
BNX_DIR_EXT_NONE, 0, 0, buf, datalen)) {
NL_SET_ERR_MSG_MOD(extack, "nvm test vpd write error");
goto err;
goto done;
}

return true;
rc = true;

err:
done:
kfree(buf);
return false;
return rc;
}

static bool bnxt_dl_selftest_check(struct devlink *dl, unsigned int id,
Expand Down

0 comments on commit ba077d6

Please sign in to comment.