RDMA/rxe: Fix errant WARN_ONCE in rxe_completer()

In rxe_comp.c in rxe_completer() the function free_pkt() did not clear skb
which triggered a warning at 'done:' and could possibly at 'exit:'. The
WARN_ONCE() calls are not actually needed. The call to free_pkt() is
moved to the end to clearly show that all skbs are freed.

Fixes: 899aba891cab ("RDMA/rxe: Fix FIXME in rxe_udp_encap_recv()")
Link: https://lore.kernel.org/r/20210304192048.2958-1-rpearson@hpe.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by Bob Pearson and committed by Jason Gunthorpe 545c4ab4 5e4a7ccc

Changed files
+23 -32
drivers
infiniband
sw
+23 -32
drivers/infiniband/sw/rxe/rxe_comp.c
··· 547 547 struct sk_buff *skb = NULL; 548 548 struct rxe_pkt_info *pkt = NULL; 549 549 enum comp_state state; 550 + int ret = 0; 550 551 551 552 rxe_add_ref(qp); 552 553 ··· 555 554 qp->req.state == QP_STATE_RESET) { 556 555 rxe_drain_resp_pkts(qp, qp->valid && 557 556 qp->req.state == QP_STATE_ERROR); 558 - goto exit; 557 + ret = -EAGAIN; 558 + goto done; 559 559 } 560 560 561 561 if (qp->comp.timeout) { ··· 566 564 qp->comp.timeout_retry = 0; 567 565 } 568 566 569 - if (qp->req.need_retry) 570 - goto exit; 567 + if (qp->req.need_retry) { 568 + ret = -EAGAIN; 569 + goto done; 570 + } 571 571 572 572 state = COMPST_GET_ACK; 573 573 ··· 640 636 break; 641 637 642 638 case COMPST_DONE: 643 - if (pkt) 644 - free_pkt(pkt); 645 639 goto done; 646 640 647 641 case COMPST_EXIT: ··· 662 660 qp->qp_timeout_jiffies) 663 661 mod_timer(&qp->retrans_timer, 664 662 jiffies + qp->qp_timeout_jiffies); 665 - goto exit; 663 + ret = -EAGAIN; 664 + goto done; 666 665 667 666 case COMPST_ERROR_RETRY: 668 667 /* we come here if the retry timer fired and we did ··· 675 672 */ 676 673 677 674 /* there is nothing to retry in this case */ 678 - if (!wqe || (wqe->state == wqe_state_posted)) 679 - goto exit; 675 + if (!wqe || (wqe->state == wqe_state_posted)) { 676 + pr_warn("Retry attempted without a valid wqe\n"); 677 + ret = -EAGAIN; 678 + goto done; 679 + } 680 680 681 681 /* if we've started a retry, don't start another 682 682 * retry sequence, unless this is a timeout. 683 683 */ 684 684 if (qp->comp.started_retry && 685 - !qp->comp.timeout_retry) { 686 - if (pkt) 687 - free_pkt(pkt); 685 + !qp->comp.timeout_retry) 688 686 goto done; 689 - } 690 687 691 688 if (qp->comp.retry_cnt > 0) { 692 689 if (qp->comp.retry_cnt != 7) ··· 707 704 qp->comp.started_retry = 1; 708 705 rxe_run_task(&qp->req.task, 0); 709 706 } 710 - if (pkt) 711 - free_pkt(pkt); 712 707 goto done; 713 708 714 709 } else { ··· 727 726 mod_timer(&qp->rnr_nak_timer, 728 727 jiffies + rnrnak_jiffies(aeth_syn(pkt) 729 728 & ~AETH_TYPE_MASK)); 730 - free_pkt(pkt); 731 - goto exit; 729 + ret = -EAGAIN; 730 + goto done; 732 731 } else { 733 732 rxe_counter_inc(rxe, 734 733 RXE_CNT_RNR_RETRY_EXCEEDED); ··· 741 740 WARN_ON_ONCE(wqe->status == IB_WC_SUCCESS); 742 741 do_complete(qp, wqe); 743 742 rxe_qp_error(qp); 744 - if (pkt) 745 - free_pkt(pkt); 746 - goto exit; 743 + ret = -EAGAIN; 744 + goto done; 747 745 } 748 746 } 749 747 750 - exit: 751 - /* we come here if we are done with processing and want the task to 752 - * exit from the loop calling us 753 - */ 754 - WARN_ON_ONCE(skb); 755 - rxe_drop_ref(qp); 756 - return -EAGAIN; 757 - 758 748 done: 759 - /* we come here if we have processed a packet we want the task to call 760 - * us again to see if there is anything else to do 761 - */ 762 - WARN_ON_ONCE(skb); 749 + if (pkt) 750 + free_pkt(pkt); 763 751 rxe_drop_ref(qp); 764 - return 0; 752 + 753 + return ret; 765 754 }