Skip to content

Commit

Permalink
mlx5: Fail in create_cq if uar_page_index size is unsupported
Browse files Browse the repository at this point in the history
[ Upstream commit 4513613 ]

The mlx5_ib_create_cq struct only has a 16 bit field for the uar page
index. Therefore, if the caller attempts to create a CQ with a uar page
index greater than or equal to 2^16, the function will fail explicitly
to avoid overflowing the struct field.

Fixes: 0c7212c ("mlx5: Support dyn UAR for CQ")
Signed-off-by: Akiva Goldberger <agoldberger@nvidia.com>
Reviewed-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
  • Loading branch information
Akiva Goldberger authored and nmorey committed Jul 8, 2024
1 parent b61fbac commit 6c96e44
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions providers/mlx5/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,12 @@ static struct ibv_cq_ex *create_cq(struct ibv_context *context,
cmd_drv->flags |= MLX5_IB_CREATE_CQ_FLAGS_REAL_TIME_TS;

if (mctx->nc_uar) {
if (mctx->nc_uar->page_id >= (1ul << 16)) {
mlx5_dbg(fp, MLX5_DBG_CQ,
"UAR page index larger than 16 bits is not supported\n");
errno = EINVAL;
goto err_db;
}
cmd_drv->flags |= MLX5_IB_CREATE_CQ_FLAGS_UAR_PAGE_INDEX;
cmd_drv->uar_page_index = mctx->nc_uar->page_id;
}
Expand Down

0 comments on commit 6c96e44

Please sign in to comment.