Skip to content

Commit

Permalink
providers/qedr: Fix qelr_alloc_context error flow
Browse files Browse the repository at this point in the history
Fix the error flow of qelr_alloc_context() by making sure to free the
allocated resources.

Fixes: cae4a99 ("libqedr: add support for XRC-SRQ's.")
Signed-off-by: Kamal Heib <[email protected]>
  • Loading branch information
Kamalheib committed Mar 1, 2024
1 parent fa69670 commit 7ffc47d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions providers/qedr/qelr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
ctx->srq_table = calloc(QELR_MAX_SRQ_ID, sizeof(*ctx->srq_table));
if (!ctx->srq_table) {
DP_ERR(ctx->dbg_fp, "failed to allocate srq_table\n");
return NULL;
goto cmd_err;
}

ctx->kernel_page_size = sysconf(_SC_PAGESIZE);
Expand Down Expand Up @@ -257,11 +257,14 @@ static struct verbs_context *qelr_alloc_context(struct ibv_device *ibdev,
DP_ERR(ctx->dbg_fp,
"alloc context: doorbell mapping failed resp.db_pa = %llx resp.db_size=%d context->cmd_fd=%d errno=%d\n",
resp.db_pa, resp.db_size, cmd_fd, errsv);
goto cmd_err;
goto free_srq_tbl;
}

return &ctx->ibv_ctx;

free_srq_tbl:
free(ctx->srq_table);

cmd_err:
qelr_err("%s: Failed to allocate context for device.\n", __func__);
qelr_close_debug_file(ctx);
Expand Down

0 comments on commit 7ffc47d

Please sign in to comment.