From patchwork Tue Oct 27 13:51:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 289854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE20AC388F9 for ; Tue, 27 Oct 2020 15:04:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D0D621D24 for ; Tue, 27 Oct 2020 15:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811056; bh=a9FoLFY3a0YLls1nteY7k/q1l1cCoVANCrzHmI05bkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ElNIcDqqkOT/Mc1fddlFjFLJPHN2n1sjzXTr12FzczuifOVfe/GSTnKgUevoh/Mpp nElKqlvi/HIYHF8AQCA+sfmUpm6r6VEaAVUri1dAngMKl1Wc4zttxJh82LEuj2rV85 JAgNDt6vcc2P5fex4qmTfWbjBVpiKVuSxqf/rwcA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1790265AbgJ0PEN (ORCPT ); Tue, 27 Oct 2020 11:04:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:38800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1790254AbgJ0PEN (ORCPT ); Tue, 27 Oct 2020 11:04:13 -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 9104120747; Tue, 27 Oct 2020 15:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811052; bh=a9FoLFY3a0YLls1nteY7k/q1l1cCoVANCrzHmI05bkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLy4IHtskCeSDftfyuiz6MrMnR1lp69x4zuXnIdMtjt6D5fH1vT1fRHe28fDaJXZA o4OMaPfrNxRzktGxZcAbE7hsLDz6nwbWfVghQ28RQjobuZ2AnW1sE8w1CmKGZTxSnf ciJREniU/YYLdeWwni4/rILZTO6dTComAdigMSuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kalderon , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.8 357/633] RDMA/qedr: Fix return code if accept is called on a destroyed qp Date: Tue, 27 Oct 2020 14:51:40 +0100 Message-Id: <20201027135539.434516310@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Michal Kalderon [ Upstream commit 8a5a10a1a74465065c75d9de1aa6685e1f1aa117 ] In iWARP, accept could be called after a QP is already destroyed. In this case an error should be returned and not success. Fixes: 82af6d19d8d9 ("RDMA/qedr: Fix synchronization methods and memory leaks in qedr") Link: https://lore.kernel.org/r/20200902165741.8355-5-michal.kalderon@marvell.com Signed-off-by: Michal Kalderon Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/qedr/qedr_iw_cm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c b/drivers/infiniband/hw/qedr/qedr_iw_cm.c index 97fc7dd353b04..c7169d2c69e5b 100644 --- a/drivers/infiniband/hw/qedr/qedr_iw_cm.c +++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c @@ -736,7 +736,7 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) struct qedr_dev *dev = ep->dev; struct qedr_qp *qp; struct qed_iwarp_accept_in params; - int rc = 0; + int rc; DP_DEBUG(dev, QEDR_MSG_IWARP, "Accept on qpid=%d\n", conn_param->qpn); @@ -759,8 +759,10 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) params.ord = conn_param->ord; if (test_and_set_bit(QEDR_IWARP_CM_WAIT_FOR_CONNECT, - &qp->iwarp_cm_flags)) + &qp->iwarp_cm_flags)) { + rc = -EINVAL; goto err; /* QP already destroyed */ + } rc = dev->ops->iwarp_accept(dev->rdma_ctx, ¶ms); if (rc) {