Skip to content

Commit f4f30f6

Browse files
Shruti Parabgregkh
authored andcommitted
bnxt_en: Fix coredump logic to free allocated buffer
[ Upstream commit ea9376c ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 15cb7ea commit f4f30f6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
7272
memcpy(info->dest_buf + off, dma_buf, len);
7373
} else {
7474
rc = -ENOBUFS;
75+
if (cmn_req->req_type ==
76+
cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) {
77+
kfree(info->dest_buf);
78+
info->dest_buf = NULL;
79+
}
7580
break;
7681
}
7782
}

0 commit comments

Comments
 (0)