@@ -442,7 +442,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
442442 ic -> i_send_cq = NULL ;
443443 ibdev_put_vector (rds_ibdev , ic -> i_scq_vector );
444444 rdsdebug ("ib_create_cq send failed: %d\n" , ret );
445- goto out ;
445+ goto rds_ibdev_out ;
446446 }
447447
448448 ic -> i_rcq_vector = ibdev_get_unused_vector (rds_ibdev );
@@ -456,19 +456,19 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
456456 ic -> i_recv_cq = NULL ;
457457 ibdev_put_vector (rds_ibdev , ic -> i_rcq_vector );
458458 rdsdebug ("ib_create_cq recv failed: %d\n" , ret );
459- goto out ;
459+ goto send_cq_out ;
460460 }
461461
462462 ret = ib_req_notify_cq (ic -> i_send_cq , IB_CQ_NEXT_COMP );
463463 if (ret ) {
464464 rdsdebug ("ib_req_notify_cq send failed: %d\n" , ret );
465- goto out ;
465+ goto recv_cq_out ;
466466 }
467467
468468 ret = ib_req_notify_cq (ic -> i_recv_cq , IB_CQ_SOLICITED );
469469 if (ret ) {
470470 rdsdebug ("ib_req_notify_cq recv failed: %d\n" , ret );
471- goto out ;
471+ goto recv_cq_out ;
472472 }
473473
474474 /* XXX negotiate max send/recv with remote? */
@@ -494,7 +494,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
494494 ret = rdma_create_qp (ic -> i_cm_id , ic -> i_pd , & attr );
495495 if (ret ) {
496496 rdsdebug ("rdma_create_qp failed: %d\n" , ret );
497- goto out ;
497+ goto recv_cq_out ;
498498 }
499499
500500 ic -> i_send_hdrs = ib_dma_alloc_coherent (dev ,
@@ -504,7 +504,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
504504 if (!ic -> i_send_hdrs ) {
505505 ret = - ENOMEM ;
506506 rdsdebug ("ib_dma_alloc_coherent send failed\n" );
507- goto out ;
507+ goto qp_out ;
508508 }
509509
510510 ic -> i_recv_hdrs = ib_dma_alloc_coherent (dev ,
@@ -514,40 +514,65 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
514514 if (!ic -> i_recv_hdrs ) {
515515 ret = - ENOMEM ;
516516 rdsdebug ("ib_dma_alloc_coherent recv failed\n" );
517- goto out ;
517+ goto send_hdrs_dma_out ;
518518 }
519519
520520 ic -> i_ack = ib_dma_alloc_coherent (dev , sizeof (struct rds_header ),
521521 & ic -> i_ack_dma , GFP_KERNEL );
522522 if (!ic -> i_ack ) {
523523 ret = - ENOMEM ;
524524 rdsdebug ("ib_dma_alloc_coherent ack failed\n" );
525- goto out ;
525+ goto recv_hdrs_dma_out ;
526526 }
527527
528528 ic -> i_sends = vzalloc_node (ic -> i_send_ring .w_nr * sizeof (struct rds_ib_send_work ),
529529 ibdev_to_node (dev ));
530530 if (!ic -> i_sends ) {
531531 ret = - ENOMEM ;
532532 rdsdebug ("send allocation failed\n" );
533- goto out ;
533+ goto ack_dma_out ;
534534 }
535535
536536 ic -> i_recvs = vzalloc_node (ic -> i_recv_ring .w_nr * sizeof (struct rds_ib_recv_work ),
537537 ibdev_to_node (dev ));
538538 if (!ic -> i_recvs ) {
539539 ret = - ENOMEM ;
540540 rdsdebug ("recv allocation failed\n" );
541- goto out ;
541+ goto sends_out ;
542542 }
543543
544544 rds_ib_recv_init_ack (ic );
545545
546546 rdsdebug ("conn %p pd %p cq %p %p\n" , conn , ic -> i_pd ,
547547 ic -> i_send_cq , ic -> i_recv_cq );
548548
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 );
550574 rds_ib_dev_put (rds_ibdev );
575+
551576 return ret ;
552577}
553578
0 commit comments