Skip to content

Commit ea9376c

Browse files
Shruti Parabdavem330
Shruti Parab
authored andcommitted
bnxt_en: Fix coredump logic to free allocated buffer
When handling HWRM_DBG_COREDUMP_LIST FW command in bnxt_hwrm_dbg_dma_data(), the allocated buffer info->dest_buf is not freed in the error path. In the normal path, info->dest_buf is assigned to coredump->data and it will eventually be freed after the coredump is collected. Free info->dest_buf immediately inside bnxt_hwrm_dbg_dma_data() in the error path. Fixes: c74751f ("bnxt_en: Return error if FW returns more data than dump length") Reported-by: Michael Chan <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Signed-off-by: Shruti Parab <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c2d20a3 commit ea9376c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
116116
memcpy(info->dest_buf + off, dma_buf, len);
117117
} else {
118118
rc = -ENOBUFS;
119+
if (cmn_req->req_type ==
120+
cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) {
121+
kfree(info->dest_buf);
122+
info->dest_buf = NULL;
123+
}
119124
break;
120125
}
121126
}

0 commit comments

Comments
 (0)