From patchwork Fri May 19 04:44:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 9735835 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 89732601A1 for ; Fri, 19 May 2017 04:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77CCB288AA for ; Fri, 19 May 2017 04:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C82F288CA; Fri, 19 May 2017 04:45:13 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 65C71288AA for ; Fri, 19 May 2017 04:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750830AbdESEpL (ORCPT ); Fri, 19 May 2017 00:45:11 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:34504 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdESEpK (ORCPT ); Fri, 19 May 2017 00:45:10 -0400 Received: by mail-wm0-f46.google.com with SMTP id 70so15998422wmq.1 for ; Thu, 18 May 2017 21:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2jbNTejvNn86nRJqX8aknuorDKCKaqP9STOut28oKLQ=; b=HHxpm5uPj1zJuVD79sL1z1j10tyI/uxXrcA127haxI3RuCJQNXlNa+Wi5809k5jSkZ BwwDHF/3exTQHG9XiFx87Wvm/Ur3hkdvpFZq8GfEqcVB8H3A580egfoIGRe3Sj6MRzbX fNSSQq7jFyY5O4dLb2zgt8erhuHFUZQFxgkJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2jbNTejvNn86nRJqX8aknuorDKCKaqP9STOut28oKLQ=; b=pnF82/fOrIw07OsArr8av0JGpE228oQ1IOhsRDPtOaoLqW4YxVk0xKMzlWgi5xQjmv Fj5ioH5kJYWZR++Tib55+z7COTMSGMurz6X2JEeTnL7463cmkxHAHvAtJ23/zA58+9Xr zOj+bAuSHzfBWQt1t/N1fIf25Xb0UV1afz7I45EX+OiUS6mSHdDM8kMMo8BE+9w7L/8I oXug7c2bgKqrQY772R/3raJXcU5r1yo3zpUxKCXp6eIrgfFDdulgbKjrnjzNoJ7isHUN 5uWKQ0VFFuFLAaGGa7zwze1z64d1ITWJe0BRmmwu+uQsnTemVv713pyY3nDezfc8lJH2 pmEQ== X-Gm-Message-State: AODbwcC22CEmfHzBiRHcZwa94gYTbKjG2pKa02aqRChF1YdbX6v7Ttqy D7cAzX810zDcd4bA X-Received: by 10.28.54.206 with SMTP id y75mr4670527wmh.72.1495169109300; Thu, 18 May 2017 21:45:09 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id p107sm1202508wrb.64.2017.05.18.21.45.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 21:45:08 -0700 (PDT) From: Selvin Xavier To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Selvin Xavier Subject: [PATCH V3 for-next 04/15] RDMA/bnxt_re: Dereg MR in FW before freeing the fast_reg_page_list Date: Thu, 18 May 2017 21:44:23 -0700 Message-Id: <1495169074-12641-5-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1495169074-12641-1-git-send-email-selvin.xavier@broadcom.com> References: <1495169074-12641-1-git-send-email-selvin.xavier@broadcom.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 If the host buffers are freed before destroying MR in HW, HW could try accessing these buffers. This could cause a host crash. Fixing the code to avoid this condition. Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index a89f095..e91bd68 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -3035,6 +3035,12 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr) struct bnxt_re_dev *rdev = mr->rdev; int rc = 0; + rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr); + if (rc) { + dev_err(rdev_to_dev(rdev), "Dereg MR failed: %#x\n", rc); + return rc; + } + if (mr->npages && mr->pages) { rc = bnxt_qplib_free_fast_reg_page_list(&rdev->qplib_res, &mr->qplib_frpl); @@ -3042,8 +3048,6 @@ int bnxt_re_dereg_mr(struct ib_mr *ib_mr) mr->npages = 0; mr->pages = NULL; } - rc = bnxt_qplib_free_mrw(&rdev->qplib_res, &mr->qplib_mr); - if (!IS_ERR(mr->ib_umem) && mr->ib_umem) ib_umem_release(mr->ib_umem);