@@ -442,7 +442,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
442
442
ic -> i_send_cq = NULL ;
443
443
ibdev_put_vector (rds_ibdev , ic -> i_scq_vector );
444
444
rdsdebug ("ib_create_cq send failed: %d\n" , ret );
445
- goto out ;
445
+ goto rds_ibdev_out ;
446
446
}
447
447
448
448
ic -> i_rcq_vector = ibdev_get_unused_vector (rds_ibdev );
@@ -456,19 +456,19 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
456
456
ic -> i_recv_cq = NULL ;
457
457
ibdev_put_vector (rds_ibdev , ic -> i_rcq_vector );
458
458
rdsdebug ("ib_create_cq recv failed: %d\n" , ret );
459
- goto out ;
459
+ goto send_cq_out ;
460
460
}
461
461
462
462
ret = ib_req_notify_cq (ic -> i_send_cq , IB_CQ_NEXT_COMP );
463
463
if (ret ) {
464
464
rdsdebug ("ib_req_notify_cq send failed: %d\n" , ret );
465
- goto out ;
465
+ goto recv_cq_out ;
466
466
}
467
467
468
468
ret = ib_req_notify_cq (ic -> i_recv_cq , IB_CQ_SOLICITED );
469
469
if (ret ) {
470
470
rdsdebug ("ib_req_notify_cq recv failed: %d\n" , ret );
471
- goto out ;
471
+ goto recv_cq_out ;
472
472
}
473
473
474
474
/* XXX negotiate max send/recv with remote? */
@@ -494,7 +494,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
494
494
ret = rdma_create_qp (ic -> i_cm_id , ic -> i_pd , & attr );
495
495
if (ret ) {
496
496
rdsdebug ("rdma_create_qp failed: %d\n" , ret );
497
- goto out ;
497
+ goto recv_cq_out ;
498
498
}
499
499
500
500
ic -> i_send_hdrs = ib_dma_alloc_coherent (dev ,
@@ -504,7 +504,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
504
504
if (!ic -> i_send_hdrs ) {
505
505
ret = - ENOMEM ;
506
506
rdsdebug ("ib_dma_alloc_coherent send failed\n" );
507
- goto out ;
507
+ goto qp_out ;
508
508
}
509
509
510
510
ic -> i_recv_hdrs = ib_dma_alloc_coherent (dev ,
@@ -514,40 +514,65 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
514
514
if (!ic -> i_recv_hdrs ) {
515
515
ret = - ENOMEM ;
516
516
rdsdebug ("ib_dma_alloc_coherent recv failed\n" );
517
- goto out ;
517
+ goto send_hdrs_dma_out ;
518
518
}
519
519
520
520
ic -> i_ack = ib_dma_alloc_coherent (dev , sizeof (struct rds_header ),
521
521
& ic -> i_ack_dma , GFP_KERNEL );
522
522
if (!ic -> i_ack ) {
523
523
ret = - ENOMEM ;
524
524
rdsdebug ("ib_dma_alloc_coherent ack failed\n" );
525
- goto out ;
525
+ goto recv_hdrs_dma_out ;
526
526
}
527
527
528
528
ic -> i_sends = vzalloc_node (ic -> i_send_ring .w_nr * sizeof (struct rds_ib_send_work ),
529
529
ibdev_to_node (dev ));
530
530
if (!ic -> i_sends ) {
531
531
ret = - ENOMEM ;
532
532
rdsdebug ("send allocation failed\n" );
533
- goto out ;
533
+ goto ack_dma_out ;
534
534
}
535
535
536
536
ic -> i_recvs = vzalloc_node (ic -> i_recv_ring .w_nr * sizeof (struct rds_ib_recv_work ),
537
537
ibdev_to_node (dev ));
538
538
if (!ic -> i_recvs ) {
539
539
ret = - ENOMEM ;
540
540
rdsdebug ("recv allocation failed\n" );
541
- goto out ;
541
+ goto sends_out ;
542
542
}
543
543
544
544
rds_ib_recv_init_ack (ic );
545
545
546
546
rdsdebug ("conn %p pd %p cq %p %p\n" , conn , ic -> i_pd ,
547
547
ic -> i_send_cq , ic -> i_recv_cq );
548
548
549
- out :
549
+ return ret ;
550
+
551
+ sends_out :
552
+ vfree (ic -> i_sends );
553
+ ack_dma_out :
554
+ ib_dma_free_coherent (dev , sizeof (struct rds_header ),
555
+ ic -> i_ack , ic -> i_ack_dma );
556
+ recv_hdrs_dma_out :
557
+ ib_dma_free_coherent (dev , ic -> i_recv_ring .w_nr *
558
+ sizeof (struct rds_header ),
559
+ ic -> i_recv_hdrs , ic -> i_recv_hdrs_dma );
560
+ send_hdrs_dma_out :
561
+ ib_dma_free_coherent (dev , ic -> i_send_ring .w_nr *
562
+ sizeof (struct rds_header ),
563
+ ic -> i_send_hdrs , ic -> i_send_hdrs_dma );
564
+ qp_out :
565
+ rdma_destroy_qp (ic -> i_cm_id );
566
+ recv_cq_out :
567
+ if (!ib_destroy_cq (ic -> i_recv_cq ))
568
+ ic -> i_recv_cq = NULL ;
569
+ send_cq_out :
570
+ if (!ib_destroy_cq (ic -> i_send_cq ))
571
+ ic -> i_send_cq = NULL ;
572
+ rds_ibdev_out :
573
+ rds_ib_remove_conn (rds_ibdev , conn );
550
574
rds_ib_dev_put (rds_ibdev );
575
+
551
576
return ret ;
552
577
}
553
578
0 commit comments