
Fix the problem that ret may not be assigned in the error flow of create_srq(). Fixes: b38bae4b5b9e ("libhns: Add support for lock-free SRQ") Fixes: b914c76318f5 ("libhns: Refactor the process of create_srq") Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> --- providers/hns/hns_roce_u_verbs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c index ed8a9c538..b7d5f8d8e 100644 --- a/providers/hns/hns_roce_u_verbs.c +++ b/providers/hns/hns_roce_u_verbs.c @@ -853,16 +853,20 @@ static struct ibv_srq *create_srq(struct ibv_context *context, if (pad) atomic_fetch_add(&pad->pd.refcount, 1); - if (hns_roce_srq_spinlock_init(srq, init_attr)) + ret = hns_roce_srq_spinlock_init(srq, init_attr); + if (ret) goto err_free_srq; set_srq_param(context, srq, init_attr); - if (alloc_srq_buf(srq)) + ret = alloc_srq_buf(srq); + if (ret) goto err_destroy_lock; srq->rdb = hns_roce_alloc_db(hr_ctx, HNS_ROCE_SRQ_TYPE_DB); - if (!srq->rdb) + if (!srq->rdb) { + ret = ENOMEM; goto err_srq_buf; + } ret = exec_srq_create_cmd(context, srq, init_attr); if (ret) -- 2.33.0