Skip to contentSkip to conversation

infiniband:cxgb4:Fix incorrect return statement in the function c4iw_destroy_cq

PATCH Steve Wise 1 participant 1 message Sep 1, 2015 1 message not in the archive InfiniBand

lore
Share & tools
lore

Steve Wise

author
#1 lore raw
In reply to a message not in the archive
Quoted 34 lines

-----Original Message-----
From: Nicholas Krause [mailto:[email protected]]
Sent: Sunday, August 30, 2015 3:12 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH] infiniband:cxgb4:Fix incorrect return statement in the function c4iw_destroy_cq

This fixes the incorrect return statement at the end of the function c4iw_destroy_cq's body that returns zero to instead correctly return the return value of the call to the function destroy_cq as all callers of c4iw_destroy_cq should be signaled when this call fails in order for them to handle it in their own intended error paths.

---
 drivers/infiniband/hw/cxgb4/cq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/infiniband/hw/cxgb4/cq.c +1 -0
index 92d5183..4f7af20 100644
@@ -848,6 +848,7 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq)
 {
 	struct c4iw_cq *chp;
 	struct c4iw_ucontext *ucontext;
+	int ret;
 
 	PDBG("%s ib_cq %p\n", __func__, ib_cq);
 	chp = to_c4iw_cq(ib_cq);
@@ -858,10 +859,10 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq)
 

drivers/infiniband/hw/cxgb4/cq.c int c4iw_destroy_cq(struct ib_cq *ib_cq) · line 866

Quoted 10 lines
drivers/infiniband/hw/cxgb4/cq.c +3 -3
 	ucontext = ib_cq->uobject ? to_c4iw_ucontext(ib_cq->uobject->context)
 				  : NULL;
-	destroy_cq(&chp->rhp->rdev, &chp->cq,
-		   ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx);
+	ret = destroy_cq(&chp->rhp->rdev, &chp->cq,
+			 ucontext ? &ucontext->uctx : &chp->cq.rdev->uctx);
 	kfree(chp);
-	return 0;
+	return ret;
 }

The SW CQ is destroyed regardless of any errors returned by destroy_cq(). So c4iw_destroy_cq() shouldn't return non-zero since it
is freeing the CQ memory. I think the correct change here is to only kfree(chp) if destroy_cq() returns 0.

Steve.

Quoted 4 lines
drivers/infiniband/hw/cxgb4/cq.c +0 -1
 struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
--

2.1.4