Skip to content

Commit ba077d6

Browse files
vikasbrcmkuba-moo
authored andcommitted
bnxt_en: fix memory leak in bnxt_nvm_test()
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 <vikas.gupta@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://lore.kernel.org/r/1666020742-25834-1-git-send-email-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1ca6952 commit ba077d6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action acti
613613

614614
static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack)
615615
{
616+
bool rc = false;
616617
u32 datalen;
617618
u16 index;
618619
u8 *buf;
@@ -632,20 +633,20 @@ static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack)
632633

633634
if (bnxt_get_nvram_item(bp->dev, index, 0, datalen, buf)) {
634635
NL_SET_ERR_MSG_MOD(extack, "nvm test vpd read error");
635-
goto err;
636+
goto done;
636637
}
637638

638639
if (bnxt_flash_nvram(bp->dev, BNX_DIR_TYPE_VPD, BNX_DIR_ORDINAL_FIRST,
639640
BNX_DIR_EXT_NONE, 0, 0, buf, datalen)) {
640641
NL_SET_ERR_MSG_MOD(extack, "nvm test vpd write error");
641-
goto err;
642+
goto done;
642643
}
643644

644-
return true;
645+
rc = true;
645646

646-
err:
647+
done:
647648
kfree(buf);
648-
return false;
649+
return rc;
649650
}
650651

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

0 commit comments

Comments
 (0)