Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp29372pxk; Tue, 15 Sep 2020 16:51:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwLbzpW5FrR5Ub/8raT5P+OSR3Kvh1qZ3yC6umYFSqMDd9S7DvbZDH77HRmyCFltywM1mr X-Received: by 2002:a17:906:8143:: with SMTP id z3mr22248121ejw.323.1600213905507; Tue, 15 Sep 2020 16:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600213905; cv=none; d=google.com; s=arc-20160816; b=qeAi2S5MVHJXobWF081mkf1uZGnUciSF7TjzkOrhtceJ9NsVK4fz7+VogncPXEVFrS k/ye3kF9BlAAHfKGgO+532WWAZUCG6jtzrhlBi3QLvoXmUiZazcYMClPFvYWgPWU5jPN VBgmSgp3XLdFzugLAPxmxD8NS71fItkhPnwTy3cpCzMO9kh3RgUl9NUup/eyDeoi4lKw hnX3FInDOPbplkyEcu3iOhFU/9j/KwPmiKn467ujlxToPEUGYyyGZBH7JYnlWqjGmEn2 WWeBKCBdDl2fg6rdAoXkv0rxVEkHm64Vy4Rh1v81krYz2JChwcgIKNY/jWqTCIOiHzgC 6RUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fkwsCr61tLMASJ27iLAKgdJH45edI9KQ7g6MufEI1a8=; b=rW3kpE8YaEDQvGWRZ6YBha3/kdFpClOxFfZixgoDmmT7O7pn+NOfU+0MMshvYdFKud LFMHMG86oFn5tjotigDn2s2mnhfrkrkupzYgVfvoTflIA8R5m8plbBcFCeHzBL+cJblA 7gErVZY+gID9FbwhOE6OuAy2oQ7hKBeKe2ZksWA8BZ1X6bIs5e87rN59o4LntP33fMbH iogpXNbI5iVe40cZW94mWqP5JjwMcKU4pU0EVVHrQoAqasTWp9fPgToUKuyutOcpsErv oa9PqH2facmwoKZWI6ciQoZwW2GGZxMNloY6t+Y8IOGlHvKa4SRkx304OsVxZ8EDP3MH Keqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pbAGdXvl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si10659553edw.331.2020.09.15.16.51.23; Tue, 15 Sep 2020 16:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pbAGdXvl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgIOXs0 (ORCPT + 99 others); Tue, 15 Sep 2020 19:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:46442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbgIOOdX (ORCPT ); Tue, 15 Sep 2020 10:33:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FBE323BED; Tue, 15 Sep 2020 14:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179900; bh=IeJLKUT8VW1wu2rKMjdTyQF5OIjbyfww4mhjyWpYV5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbAGdXvlbiCNe+9gPPMKJB6uJkD5s6/2hXJP0nrwDTFNJmTR7hv9PBR6bZgXL5Cqu xRPVmmRJv/ktWBh26DCPxgX5lig26gxpRN0zqjIjHcdGdaGLYRa5NrO2wzbljhHdDZ vdMlZjNhUtGWdl2RSZ48ZjoHFIvIwgQ9J9N1Pz5c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Selvin Xavier , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.8 022/177] RDMA/bnxt_re: Remove the qp from list only if the qp destroy succeeds Date: Tue, 15 Sep 2020 16:11:33 +0200 Message-Id: <20200915140654.713479340@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Selvin Xavier [ Upstream commit 097a9d23b7250355b182c5fd47dd4c55b22b1c33 ] Driver crashes when destroy_qp is re-tried because of an error returned. This is because the qp entry was removed from the qp list during the first call. Remove qp from the list only if destroy_qp returns success. The driver will still trigger a WARN_ON due to the memory leaking, but at least it isn't corrupting memory too. Fixes: 8dae419f9ec7 ("RDMA/bnxt_re: Refactor queue pair creation code") Link: https://lore.kernel.org/r/1598292876-26529-2-git-send-email-selvin.xavier@broadcom.com Signed-off-by: Selvin Xavier Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index dad38aa06403d..cb6e873039df5 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -752,12 +752,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp) gsi_sqp = rdev->gsi_ctx.gsi_sqp; gsi_sah = rdev->gsi_ctx.gsi_sah; - /* remove from active qp list */ - mutex_lock(&rdev->qp_lock); - list_del(&gsi_sqp->list); - mutex_unlock(&rdev->qp_lock); - atomic_dec(&rdev->qp_count); - ibdev_dbg(&rdev->ibdev, "Destroy the shadow AH\n"); bnxt_qplib_destroy_ah(&rdev->qplib_res, &gsi_sah->qplib_ah, @@ -772,6 +766,12 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp) } bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp); + /* remove from active qp list */ + mutex_lock(&rdev->qp_lock); + list_del(&gsi_sqp->list); + mutex_unlock(&rdev->qp_lock); + atomic_dec(&rdev->qp_count); + kfree(rdev->gsi_ctx.sqp_tbl); kfree(gsi_sah); kfree(gsi_sqp); @@ -792,11 +792,6 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata) unsigned int flags; int rc; - mutex_lock(&rdev->qp_lock); - list_del(&qp->list); - mutex_unlock(&rdev->qp_lock); - atomic_dec(&rdev->qp_count); - bnxt_qplib_flush_cqn_wq(&qp->qplib_qp); rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp); @@ -819,6 +814,11 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata) goto sh_fail; } + mutex_lock(&rdev->qp_lock); + list_del(&qp->list); + mutex_unlock(&rdev->qp_lock); + atomic_dec(&rdev->qp_count); + ib_umem_release(qp->rumem); ib_umem_release(qp->sumem); -- 2.25.1