Skip to content

Commit c221dd1

Browse files
solbjorndavem330
authored andcommitted
net: qed: reset ILT block sizes before recomputing to fix crashes
Sizes of all ILT blocks must be reset before ILT recomputing when disabling clients, or memory allocation may exceed ILT shadow array and provoke system crashes. Fixes: 1408cc1 ("qed: Introduce VFs") Signed-off-by: Alexander Lobakin <[email protected]> Signed-off-by: Igor Russkikh <[email protected]> Signed-off-by: Michal Kalderon <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ec6c805 commit c221dd1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/net/ethernet/qlogic/qed/qed_cxt.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,20 @@ static struct qed_ilt_cli_blk *qed_cxt_set_blk(struct qed_ilt_cli_blk *p_blk)
465465
return p_blk;
466466
}
467467

468+
static void qed_cxt_ilt_blk_reset(struct qed_hwfn *p_hwfn)
469+
{
470+
struct qed_ilt_client_cfg *clients = p_hwfn->p_cxt_mngr->clients;
471+
u32 cli_idx, blk_idx;
472+
473+
for (cli_idx = 0; cli_idx < MAX_ILT_CLIENTS; cli_idx++) {
474+
for (blk_idx = 0; blk_idx < ILT_CLI_PF_BLOCKS; blk_idx++)
475+
clients[cli_idx].pf_blks[blk_idx].total_size = 0;
476+
477+
for (blk_idx = 0; blk_idx < ILT_CLI_VF_BLOCKS; blk_idx++)
478+
clients[cli_idx].vf_blks[blk_idx].total_size = 0;
479+
}
480+
}
481+
468482
int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *line_count)
469483
{
470484
struct qed_cxt_mngr *p_mngr = p_hwfn->p_cxt_mngr;
@@ -484,6 +498,11 @@ int qed_cxt_cfg_ilt_compute(struct qed_hwfn *p_hwfn, u32 *line_count)
484498

485499
p_mngr->pf_start_line = RESC_START(p_hwfn, QED_ILT);
486500

501+
/* Reset all ILT blocks at the beginning of ILT computing in order
502+
* to prevent memory allocation for irrelevant blocks afterwards.
503+
*/
504+
qed_cxt_ilt_blk_reset(p_hwfn);
505+
487506
DP_VERBOSE(p_hwfn, QED_MSG_ILT,
488507
"hwfn [%d] - Set context manager starting line to be 0x%08x\n",
489508
p_hwfn->my_id, p_hwfn->p_cxt_mngr->pf_start_line);

0 commit comments

Comments
 (0)