diff mbox series

[12/13] RDMA/srpt: Rework the srpt_alloc_srq() error path

Message ID 20181214005851.176412-13-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series Add support for immediate data to the SRP drivers | expand

Commit Message

Bart Van Assche Dec. 14, 2018, 12:58 a.m. UTC
This patch does not change any functionality but makes the next patch
easier to read.

Cc: Sergey Gorenko <sergeygo@mellanox.com>
Cc: Max Gurtovoy <maxg@mellanox.com>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 2e3ba767e614..584cb81733df 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2936,10 +2936,8 @@  static int srpt_alloc_srq(struct srpt_device *sdev)
 		srpt_alloc_ioctx_ring(sdev, sdev->srq_size,
 				      sizeof(*sdev->ioctx_ring[0]),
 				      srp_max_req_size, DMA_FROM_DEVICE);
-	if (!sdev->ioctx_ring) {
-		ib_destroy_srq(srq);
-		return -ENOMEM;
-	}
+	if (!sdev->ioctx_ring)
+		goto free_srq;
 
 	sdev->use_srq = true;
 	sdev->srq = srq;
@@ -2950,6 +2948,10 @@  static int srpt_alloc_srq(struct srpt_device *sdev)
 	}
 
 	return 0;
+
+free_srq:
+	ib_destroy_srq(srq);
+	return -ENOMEM;
 }
 
 static int srpt_use_srq(struct srpt_device *sdev, bool use_srq)