Skip to content

Commit 349e3c0

Browse files
Kalesh APjgunthorpe
authored andcommitted
RDMA/bnxt_re: Fix a possible memory leak
Inside bnxt_qplib_create_cq(), when the check for NULL DPI fails, driver returns directly without freeing the memory allocated inside bnxt_qplib_alloc_init_hwq() routine. Fixed this by moving the check for NULL DPI before invoking bnxt_qplib_alloc_init_hwq(). Fixes: 1ac5a40 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kashyap Desai <[email protected]> Signed-off-by: Kalesh AP <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 56518a6 commit 349e3c0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,12 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
20562056
u32 pg_sz_lvl;
20572057
int rc;
20582058

2059+
if (!cq->dpi) {
2060+
dev_err(&rcfw->pdev->dev,
2061+
"FP: CREATE_CQ failed due to NULL DPI\n");
2062+
return -EINVAL;
2063+
}
2064+
20592065
hwq_attr.res = res;
20602066
hwq_attr.depth = cq->max_wqe;
20612067
hwq_attr.stride = sizeof(struct cq_base);
@@ -2069,11 +2075,6 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
20692075
CMDQ_BASE_OPCODE_CREATE_CQ,
20702076
sizeof(req));
20712077

2072-
if (!cq->dpi) {
2073-
dev_err(&rcfw->pdev->dev,
2074-
"FP: CREATE_CQ failed due to NULL DPI\n");
2075-
return -EINVAL;
2076-
}
20772078
req.dpi = cpu_to_le32(cq->dpi->dpi);
20782079
req.cq_handle = cpu_to_le64(cq->cq_handle);
20792080
req.cq_size = cpu_to_le32(cq->hwq.max_elements);

0 commit comments

Comments
 (0)