Skip to content

Commit

Permalink
qed: Fix a potential use-after-free in qed_cxt_tables_alloc
Browse files Browse the repository at this point in the history
qed_ilt_shadow_alloc() will call qed_ilt_shadow_free() to
free p_hwfn->p_cxt_mngr->ilt_shadow on error. However,
qed_cxt_tables_alloc() accesses the freed pointer on failure
of qed_ilt_shadow_alloc() through calling qed_cxt_mngr_free(),
which may lead to use-after-free. Fix this issue by setting
p_mngr->ilt_shadow to NULL in qed_ilt_shadow_free().

Fixes: fe56b9e ("qed: Add module with basic common support")
Reviewed-by: Przemek Kitszel <[email protected]>
Signed-off-by: Dinghao Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
dinghaoliu authored and kuba-moo committed Dec 12, 2023
1 parent 810c38a commit b65d52a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/qlogic/qed/qed_cxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ static void qed_ilt_shadow_free(struct qed_hwfn *p_hwfn)
p_dma->virt_addr = NULL;
}
kfree(p_mngr->ilt_shadow);
p_mngr->ilt_shadow = NULL;
}

static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
Expand Down

0 comments on commit b65d52a

Please sign in to comment.