Commit c53bdb96 authored by Junxian Huang's avatar Junxian Huang
Browse files

RDMA/hns: Fix udca not unregistered when reset entry allocation failed

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBSE4C



----------------------------------------------------------------------

hns_roce_unregister_udca() is not called when
hns_roce_alloc_reset_entry() failed. Reorder the sequence of error
path in hns_roce_alloc_ucontext() to fix it. Besides, to keep the
coding constant, reorder hns_roce_dealloc_ucontext() accordingly
as well.

Fixes: 754c3a8a ("RDMA/hns: Use one CQ bank per context")
Fixes: e8b1fec4 ("RDMA/hns: Kernel notify usr space to stop ring db")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 7fd63fd6
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -633,10 +633,10 @@ static int hns_roce_alloc_ucontext(struct ib_ucontext *uctx,
	return 0;

error_fail_copy_to_udata:
	hns_roce_unregister_udca(hr_dev, context);
	hns_roce_dealloc_reset_entry(context);

error_fail_reset_entry:
	hns_roce_unregister_udca(hr_dev, context);
	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&context->page_mutex);
@@ -656,20 +656,20 @@ static void hns_roce_dealloc_ucontext(struct ib_ucontext *ibcontext)
	struct hns_roce_ucontext *context = to_hr_ucontext(ibcontext);
	struct hns_roce_dev *hr_dev = to_hr_dev(ibcontext->device);

	hns_roce_put_cq_bankid_for_uctx(context);
	hns_roce_unregister_uctx_debugfs(context);

	mutex_lock(&hr_dev->uctx_list_mutex);
	list_del(&context->list);
	mutex_unlock(&hr_dev->uctx_list_mutex);

	hns_roce_unregister_uctx_debugfs(context);

	hns_roce_dealloc_reset_entry(context);
	hns_roce_unregister_udca(hr_dev, context);
	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB)
		mutex_destroy(&context->page_mutex);

	hns_roce_put_cq_bankid_for_uctx(context);
	hns_roce_dealloc_uar_entry(context);
	hns_roce_dealloc_reset_entry(context);

	ida_free(&hr_dev->uar_ida.ida, (int)context->uar.logic_idx);
}