From patchwork Thu Dec 8 18:16:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikolova, Tatyana E" X-Patchwork-Id: 9466937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B06F3607D3 for ; Thu, 8 Dec 2016 18:17:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A64C7285F2 for ; Thu, 8 Dec 2016 18:17:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A9EA285F7; Thu, 8 Dec 2016 18:17:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15D42285FB for ; Thu, 8 Dec 2016 18:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752819AbcLHSRQ (ORCPT ); Thu, 8 Dec 2016 13:17:16 -0500 Received: from mga06.intel.com ([134.134.136.31]:25008 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbcLHSRH (ORCPT ); Thu, 8 Dec 2016 13:17:07 -0500 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 08 Dec 2016 10:17:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,320,1477983600"; d="scan'208";a="38311234" Received: from tenikolo-mobl2.amr.corp.intel.com ([10.122.42.65]) by orsmga004.jf.intel.com with ESMTP; 08 Dec 2016 10:17:05 -0800 From: Tatyana Nikolova To: jgunthorpe@obsidianresearch.com, dledford@redhat.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, e1000-rdma@lists.sourceforge.net Subject: [PATCH rdma-core 06/10] i40iw: Return correct error codes for destroy QP and CQ Date: Thu, 8 Dec 2016 12:16:37 -0600 Message-Id: <1481221001-1044-7-git-send-email-tatyana.e.nikolova@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481221001-1044-1-git-send-email-tatyana.e.nikolova@intel.com> References: <1481221001-1044-1-git-send-email-tatyana.e.nikolova@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shiraz Saleem Return correct error codes to application if destroy QP or CQ fails. Make sure to deregister memory only if the destroy is successful. Signed-off-by: Shiraz Saleem Signed-off-by: Tatyana Nikolova --- providers/i40iw/i40iw_uverbs.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/providers/i40iw/i40iw_uverbs.c b/providers/i40iw/i40iw_uverbs.c index 651a91d..ef381ed 100644 --- a/providers/i40iw/i40iw_uverbs.c +++ b/providers/i40iw/i40iw_uverbs.c @@ -305,9 +305,11 @@ int i40iw_udestroy_cq(struct ibv_cq *cq) struct i40iw_ucq *iwucq = to_i40iw_ucq(cq); int ret; + ret = ibv_cmd_destroy_cq(cq); + if (ret) + return ret; + ibv_cmd_dereg_mr(&iwucq->mr); - if (ibv_cmd_destroy_cq(cq)) - fprintf(stderr, PFX "%s: failed to destroy CQ\n", __func__); free(iwucq->cq.cq_base); ret = pthread_spin_destroy(&iwucq->lock); @@ -460,16 +462,24 @@ void i40iw_cq_event(struct ibv_cq *cq) pthread_spin_unlock(&iwucq->lock); } -static void i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp, +static int i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp, struct i40iw_qp_quanta *sq_base) { + int ret; + + ret = ibv_cmd_destroy_qp(&iwuqp->ibv_qp); + if (ret) + return ret; + if (iwuqp->push_db) munmap(iwuqp->push_db, I40IW_HW_PAGE_SIZE); if (iwuqp->push_wqe) munmap(iwuqp->push_wqe, I40IW_HW_PAGE_SIZE); - ibv_cmd_destroy_qp(&iwuqp->ibv_qp); + ibv_cmd_dereg_mr(&iwuqp->mr); free((void *)sq_base); + + return 0; } /** @@ -759,7 +769,9 @@ int i40iw_udestroy_qp(struct ibv_qp *qp) struct i40iw_uqp *iwuqp = to_i40iw_uqp(qp); int ret; - i40iw_destroy_vmapped_qp(iwuqp, iwuqp->qp.sq_base); + ret = i40iw_destroy_vmapped_qp(iwuqp, iwuqp->qp.sq_base); + if (ret) + return ret; if (iwuqp->qp.sq_wrtrk_array) free(iwuqp->qp.sq_wrtrk_array);