[PATCH rdma-core 6/7] libhns: Avoid null pointer operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Lijun Ou <oulijun@xxxxxxxxxx>

When recv cq or send cq doesn't exist, clean cq will lead to a null pointer
error in hns_roce_u_v2_destroy_qp().

Fixes: 6fe30a1a705f ("libhns: Introduce QP operations referred to hip08 RoCE device")
Signed-off-by: Lijun Ou <oulijun@xxxxxxxxxx>
Signed-off-by: Weihang Li <liweihang@xxxxxxxxxxxxx>
---
 providers/hns/hns_roce_u_hw_v2.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c
index 7f5a2ce..64dea8e 100644
--- a/providers/hns/hns_roce_u_hw_v2.c
+++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -1181,10 +1181,11 @@ static int hns_roce_u_v2_destroy_qp(struct ibv_qp *ibqp)
 
 	hns_roce_lock_cqs(ibqp);
 
-	__hns_roce_v2_cq_clean(to_hr_cq(ibqp->recv_cq), ibqp->qp_num,
-			       ibqp->srq ? to_hr_srq(ibqp->srq) : NULL);
+	if (ibqp->recv_cq)
+		__hns_roce_v2_cq_clean(to_hr_cq(ibqp->recv_cq), ibqp->qp_num,
+				       ibqp->srq ? to_hr_srq(ibqp->srq) : NULL);
 
-	if (ibqp->send_cq != ibqp->recv_cq)
+	if (ibqp->send_cq && ibqp->send_cq != ibqp->recv_cq)
 		__hns_roce_v2_cq_clean(to_hr_cq(ibqp->send_cq), ibqp->qp_num,
 				       NULL);
 
-- 
2.8.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux