Commit 278c18a4 authored by Junxian Huang's avatar Junxian Huang Committed by Leon Romanovsky
Browse files

RDMA/hns: Fix accessing uninitialized resources



hr_dev->pgdir_list and hr_dev->pgdir_mutex won't be initialized if
CQ/QP record db are not enabled, but they are also needed when using
SRQ with SRQ record db enabled. Simplified the logic by always
initailizing the reosurces.

Fixes: c9813b0b ("RDMA/hns: Support SRQ record doorbell")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20250703113905.3597124-5-huangjunxian6@hisilicon.com


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 2c2ec010
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -937,9 +937,6 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)
static void hns_roce_teardown_hca(struct hns_roce_dev *hr_dev)
{
	hns_roce_cleanup_bitmap(hr_dev);

	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(&hr_dev->pgdir_mutex);
}

@@ -958,11 +955,8 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)
	INIT_LIST_HEAD(&hr_dev->qp_list);
	spin_lock_init(&hr_dev->qp_list_lock);

	if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_CQ_RECORD_DB ||
	    hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_RECORD_DB) {
	INIT_LIST_HEAD(&hr_dev->pgdir_list);
	mutex_init(&hr_dev->pgdir_mutex);
	}

	hns_roce_init_uar_table(hr_dev);

@@ -994,8 +988,6 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)

err_uar_table_free:
	ida_destroy(&hr_dev->uar_ida.ida);
	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(&hr_dev->pgdir_mutex);

	return ret;