Skip to content

Commit b9f59a2

Browse files
Junxian Huangrleon
authored andcommitted
RDMA/hns: Fix unmatched condition in error path of alloc_user_qp_db()
Currently the condition of unmapping sdb in error path is not exactly the same as the condition of mapping in alloc_user_qp_db(). This may cause a problem of unmapping an unmapped db in some case, such as when the QP is XRC TGT. Unified the two conditions. Fixes: 90ae0b5 ("RDMA/hns: Combine enable flags of qp") Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com> Link: https://patch.msgid.link/20250311084857.3803665-4-huangjunxian6@hisilicon.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 2565558 commit b9f59a2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/infiniband/hw/hns/hns_roce_qp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,14 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
868868
struct hns_roce_ib_create_qp *ucmd,
869869
struct hns_roce_ib_create_qp_resp *resp)
870870
{
871+
bool has_sdb = user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd);
871872
struct hns_roce_ucontext *uctx = rdma_udata_to_drv_context(udata,
872873
struct hns_roce_ucontext, ibucontext);
874+
bool has_rdb = user_qp_has_rdb(hr_dev, init_attr, udata, resp);
873875
struct ib_device *ibdev = &hr_dev->ib_dev;
874876
int ret;
875877

876-
if (user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd)) {
878+
if (has_sdb) {
877879
ret = hns_roce_db_map_user(uctx, ucmd->sdb_addr, &hr_qp->sdb);
878880
if (ret) {
879881
ibdev_err(ibdev,
@@ -884,7 +886,7 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
884886
hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
885887
}
886888

887-
if (user_qp_has_rdb(hr_dev, init_attr, udata, resp)) {
889+
if (has_rdb) {
888890
ret = hns_roce_db_map_user(uctx, ucmd->db_addr, &hr_qp->rdb);
889891
if (ret) {
890892
ibdev_err(ibdev,
@@ -898,7 +900,7 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
898900
return 0;
899901

900902
err_sdb:
901-
if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
903+
if (has_sdb)
902904
hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
903905
err_out:
904906
return ret;

0 commit comments

Comments
 (0)