mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
RDMA/hns: Fix unmatched condition in error path of alloc_user_qp_db()
[ Upstream commit b9f59a24ba35a7d955a9f8e148dd9f85b7b40a01 ]
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: 90ae0b57e4 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4104b0023f
commit
21c3be4924
@@ -924,12 +924,14 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
|
|||||||
struct hns_roce_ib_create_qp *ucmd,
|
struct hns_roce_ib_create_qp *ucmd,
|
||||||
struct hns_roce_ib_create_qp_resp *resp)
|
struct hns_roce_ib_create_qp_resp *resp)
|
||||||
{
|
{
|
||||||
|
bool has_sdb = user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd);
|
||||||
struct hns_roce_ucontext *uctx = rdma_udata_to_drv_context(udata,
|
struct hns_roce_ucontext *uctx = rdma_udata_to_drv_context(udata,
|
||||||
struct hns_roce_ucontext, ibucontext);
|
struct hns_roce_ucontext, ibucontext);
|
||||||
|
bool has_rdb = user_qp_has_rdb(hr_dev, init_attr, udata, resp);
|
||||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (user_qp_has_sdb(hr_dev, init_attr, udata, resp, ucmd)) {
|
if (has_sdb) {
|
||||||
ret = hns_roce_db_map_user(uctx, ucmd->sdb_addr, &hr_qp->sdb);
|
ret = hns_roce_db_map_user(uctx, ucmd->sdb_addr, &hr_qp->sdb);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ibdev_err(ibdev,
|
ibdev_err(ibdev,
|
||||||
@@ -940,7 +942,7 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
|
|||||||
hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
|
hr_qp->en_flags |= HNS_ROCE_QP_CAP_SQ_RECORD_DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_qp_has_rdb(hr_dev, init_attr, udata, resp)) {
|
if (has_rdb) {
|
||||||
ret = hns_roce_db_map_user(uctx, ucmd->db_addr, &hr_qp->rdb);
|
ret = hns_roce_db_map_user(uctx, ucmd->db_addr, &hr_qp->rdb);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ibdev_err(ibdev,
|
ibdev_err(ibdev,
|
||||||
@@ -954,7 +956,7 @@ static int alloc_user_qp_db(struct hns_roce_dev *hr_dev,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_sdb:
|
err_sdb:
|
||||||
if (hr_qp->en_flags & HNS_ROCE_QP_CAP_SQ_RECORD_DB)
|
if (has_sdb)
|
||||||
hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
|
hns_roce_db_unmap_user(uctx, &hr_qp->sdb);
|
||||||
err_out:
|
err_out:
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user