Skip to contentSkip to conversation

qedr: Unlock on error in qedr_post_send()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 15, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qedr: Unlock on error in qedr_post_send()

If "wr" is NULL then we return without unlocking. I added an unlock label and changed the direct returns to gotos.

Fixes afa0e13be754 ("qedr: Add support for data path")
drivers/infiniband/hw/qedr/verbs.c +5 -3
index a615142..01d05b0 100644
@@ -2973,17 +2973,18 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 	if ((qp->state = QED_ROCE_QP_STATE_RESET) ||
 	    (qp->state = QED_ROCE_QP_STATE_ERR)) {
-		spin_unlock_irqrestore(&qp->q_lock, flags);
 		*bad_wr = wr;
 		DP_DEBUG(dev, QEDR_MSG_CQ,
 			 "QP in wrong state! QP icid=0x%x state %d\n",
 			 qp->icid, qp->state);
-		return -EINVAL;
+		rc = -EINVAL;
+		goto unlock;
 	}
 
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto unlock;
 	}
 
 	while (wr) {
@@ -3012,6 +3013,7 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	/* Make sure write sticks */
 	mmiowb();
 
+unlock:
 	spin_unlock_irqrestore(&qp->q_lock, flags);
 
 	return rc;
#1 lore raw
Quoted 42 lines

If "wr" is NULL then we return without unlocking. I added an unlock label and changed the direct returns to gotos.

Fixes afa0e13be754 ("qedr: Add support for data path")
drivers/infiniband/hw/qedr/verbs.c +4 -3
index a615142..01d05b0 100644
@@ -2973,17 +2973,18 @@ int qedr_post_send(struct ib_qp *ibqp, struct
 ib_send_wr *wr,
 
 	if ((qp->state == QED_ROCE_QP_STATE_RESET) ||
 	    (qp->state == QED_ROCE_QP_STATE_ERR)) {
-		spin_unlock_irqrestore(&qp->q_lock, flags);
 		*bad_wr = wr;
 		DP_DEBUG(dev, QEDR_MSG_CQ,
 			 "QP in wrong state! QP icid=0x%x state %d\n",
 			 qp->icid, qp->state);
-		return -EINVAL;
+		rc = -EINVAL;
+		goto unlock;
 	}
 
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto unlock;
 	}
 
drivers/infiniband/hw/qedr/verbs.c +1 -0
 	while (wr) {
@@ -3012,6 +3013,7 @@ int qedr_post_send(struct ib_qp *ibqp, struct
 ib_send_wr *wr,
 	/* Make sure write sticks */
 	mmiowb();
 
+unlock:
 	spin_unlock_irqrestore(&qp->q_lock, flags);
 
Quoted 1 line

return rc;

Thanks for catching this. However this was already taken care of by Wei Yongjun in a different manner.
See: https://patchwork.kernel.org/patch/9409053/

Thanks,
Ram