Skip to contentSkip to conversation

qedr: Fix missing unlock on error in qedr_post_send()

PATCH In review Wei Yongjun 4 participants 7 messages Oct 28, 2016 – Dec 14, 2016 4 messages not in the archive

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

PATCH 1/1 qedr: Fix missing unlock on error in qedr_post_send()

From: Wei Yongjun <[email protected]>

Add the missing unlock before return from function qedr_post_send() in the error handling case.

---
 drivers/infiniband/hw/qedr/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/qedr/verbs.c +3 -1
index a615142..e7c7417 100644
@@ -2983,7 +2983,8 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out_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();
 
+out_unlock:
 	spin_unlock_irqrestore(&qp->q_lock, flags);
 
 	return rc;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to a message not in the archive
Quoted 15 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Add the missing unlock before return from function qedr_post_send() in the error handling case.

---
 drivers/infiniband/hw/qedr/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/qedr/verbs.c +0 -0
index a615142..e7c7417 100644

drivers/infiniband/hw/qedr/verbs.c int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · line 2988

Quoted 7 lines
drivers/infiniband/hw/qedr/verbs.c +2 -1
@@ -2983,7 +2983,8 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out_unlock;
 	}

IMHO, this if needs to be moved to be before acquiring spinlock and avoid introducing new labels for this one case only.

Quoted 17 lines
drivers/infiniband/hw/qedr/verbs.c +1 -1
 	while (wr) {
@@ -3012,6 +3013,7 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 	/* Make sure write sticks */
 	mmiowb();
 
+out_unlock:
 	spin_unlock_irqrestore(&qp->q_lock, flags);
 
 	return rc;
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive
Quoted 6 lines
Quoted 6 lines

index a615142..e7c7417 100644

drivers/infiniband/hw/qedr/verbs.c +0 -0
@@ -2983,7 +2983,8 @@ int qedr_post_send(struct ib_qp *ibqp, struct
 ib_send_wr *wr,
 
Quoted 10 lines

drivers/infiniband/hw/qedr/verbs.c int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · line 2988

Quoted 6 lines
drivers/infiniband/hw/qedr/verbs.c +2 -1
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out_unlock;
 	}

IMHO, this if needs to be moved to be before acquiring spinlock and avoid introducing new labels for this one case only.

Thanks Wei and Leon.

Actually, perhaps we can totally remove the check itself -
Since this is kernel space, is it safe to presume that all ULPs are trusted to be well coded? (if not, and as a side note, I see that in MLX4 there's a for(..;wr;..) loop, but that wr is dereferenced earlier so perhaps this is a potential bug)

Ram

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH v2 1/1 qedr: remove pointless NULL check in qedr_post_send()

In reply to a message not in the archive

From: Wei Yongjun <[email protected]>

Remove pointless NULL check for 'wr' in qedr_post_send().

---
v1 -> v2: remove pointless NULL check as Ram's suggestion

---
 drivers/infiniband/hw/qedr/verbs.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/infiniband/hw/qedr/verbs.c +0 -5
index a615142..ed7521a 100644
@@ -2981,11 +2981,6 @@ int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 		return -EINVAL;
 	}
 
-	if (!wr) {
-		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
-	}
-
 	while (wr) {
 		rc = __qedr_post_send(ibqp, wr, bad_wr);
 		if (rc)

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive
Quoted 17 lines · Ram
Quoted 6 lines
Quoted 6 lines

index a615142..e7c7417 100644

drivers/infiniband/hw/qedr/verbs.c +0 -0
@@ -2983,7 +2983,8 @@ int qedr_post_send(struct ib_qp *ibqp, struct
 ib_send_wr *wr,
 
Quoted 10 lines

drivers/infiniband/hw/qedr/verbs.c int qedr_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, · line 2988

Quoted 6 lines
drivers/infiniband/hw/qedr/verbs.c +2 -1
 	if (!wr) {
 		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
+		rc = -EINVAL;
+		goto out_unlock;
 	}

IMHO, this if needs to be moved to be before acquiring spinlock and avoid introducing new labels for this one case only.

Quoted 4 lines

Thanks Wei and Leon.

Actually, perhaps we can totally remove the check itself -
Since this is kernel space, is it safe to presume that all ULPs are trusted to be well coded?

I think so.

Acked-by
#9 lore raw

RE: [PATCH v2] qedr: remove pointless NULL check in qedr_post_send()

In reply to a message not in the archive
Quoted 17 lines
drivers/infiniband/hw/qedr/verbs.c +0 -5
index a615142..ed7521a 100644
@@ -2981,11 +2981,6 @@ int qedr_post_send(struct ib_qp *ibqp, struct
 ib_send_wr *wr,
 		return -EINVAL;
 	}
 
-	if (!wr) {
-		DP_ERR(dev, "Got an empty post send.\n");
-		return -EINVAL;
-	}
-
 	while (wr) {
 		rc = __qedr_post_send(ibqp, wr, bad_wr);
Quoted 1 line

if (rc)

Thanks Wei.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html