aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2010-02-24 18:07:59 -0500
committerRoland Dreier <rolandd@cisco.com>2010-03-02 02:51:39 -0500
commitda9d2f07306fc29a2f10885c2b0a463f3863c365 (patch)
tree3057204face593f4859aab958bf93e4fe9b1c98e
parent9c03dc9f19351edf25c1107e3cfd3cc538c7ab9e (diff)
IB/srp: Clean up error path in srp_create_target_ib()
Instead of repeating the error unwinding steps in each place an error can be detected, use the common idiom of gotos into an error flow. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 441ea7c2e7c4..ed3f9ebae882 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -232,15 +232,14 @@ static int srp_create_target_ib(struct srp_target_port *target)
232 srp_recv_completion, NULL, target, SRP_RQ_SIZE, 0); 232 srp_recv_completion, NULL, target, SRP_RQ_SIZE, 0);
233 if (IS_ERR(target->recv_cq)) { 233 if (IS_ERR(target->recv_cq)) {
234 ret = PTR_ERR(target->recv_cq); 234 ret = PTR_ERR(target->recv_cq);
235 goto out; 235 goto err;
236 } 236 }
237 237
238 target->send_cq = ib_create_cq(target->srp_host->srp_dev->dev, 238 target->send_cq = ib_create_cq(target->srp_host->srp_dev->dev,
239 srp_send_completion, NULL, target, SRP_SQ_SIZE, 0); 239 srp_send_completion, NULL, target, SRP_SQ_SIZE, 0);
240 if (IS_ERR(target->send_cq)) { 240 if (IS_ERR(target->send_cq)) {
241 ret = PTR_ERR(target->send_cq); 241 ret = PTR_ERR(target->send_cq);
242 ib_destroy_cq(target->recv_cq); 242 goto err_recv_cq;
243 goto out;
244 } 243 }
245 244
246 ib_req_notify_cq(target->recv_cq, IB_CQ_NEXT_COMP); 245 ib_req_notify_cq(target->recv_cq, IB_CQ_NEXT_COMP);
@@ -258,20 +257,26 @@ static int srp_create_target_ib(struct srp_target_port *target)
258 target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr); 257 target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr);
259 if (IS_ERR(target->qp)) { 258 if (IS_ERR(target->qp)) {
260 ret = PTR_ERR(target->qp); 259 ret = PTR_ERR(target->qp);
261 ib_destroy_cq(target->send_cq); 260 goto err_send_cq;
262 ib_destroy_cq(target->recv_cq);
263 goto out;
264 } 261 }
265 262
266 ret = srp_init_qp(target, target->qp); 263 ret = srp_init_qp(target, target->qp);
267 if (ret) { 264 if (ret)
268 ib_destroy_qp(target->qp); 265 goto err_qp;
269 ib_destroy_cq(target->send_cq);
270 ib_destroy_cq(target->recv_cq);
271 goto out;
272 }
273 266
274out: 267 kfree(init_attr);
268 return 0;
269
270err_qp:
271 ib_destroy_qp(target->qp);
272
273err_send_cq:
274 ib_destroy_cq(target->send_cq);
275
276err_recv_cq:
277 ib_destroy_cq(target->recv_cq);
278
279err:
275 kfree(init_attr); 280 kfree(init_attr);
276 return ret; 281 return ret;
277} 282}