Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9980071ybi; Wed, 24 Jul 2019 13:27:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFq/+XcCUpSdYJtuvcy1F37WoAvJA2l2gdRjDueilNpsFkBuPdEi9C9Dal7V1EUoOV/JFx X-Received: by 2002:a17:90a:8688:: with SMTP id p8mr90605697pjn.57.1564000056189; Wed, 24 Jul 2019 13:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000056; cv=none; d=google.com; s=arc-20160816; b=Bvz6zKtUPgBPYrCtJofPxJURcYfEtSdRE6kAQJCW8/f8r2S4c23/cqsIEddpgb78wX KVfdxLiAq6r6Ke3em+Kj5lpYJSr66PMtD5Z5buK3zn9LcVXMDmI9M+y78MnniS71i0tB 9hWxVHnbAyPiWnPYZAtsEGSQHL7tFu/oFaWNlOyGhOiOBIRDrZbc917X3X0sA5Yt82FD lZd3Y1VqZzbSWh+gVejs1OsecqvYSLA2u45yuafAuTPc70B1Ml7NP2B+yRDsBzP4JPvi waNPv2SBLMLLS2mWapTCTeaPbN5mYG6Ry5LQ2PaFCxB0EDVjeFVC8B+PNTYtM8dvTr4n G1lQ== 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=Cv/9SC1zL3JFaRcseIbbRGEB15n9iSlEqc6Ub5lIu5U=; b=EQVP0luQaefCCp91ejGmzI015xVkSiw2eWLD94ckfbX8tOE8xSf6siocEtlwPtMs/c TA+d+Edr/GCL/4E1knb39lkhblrXXsyYUCirTxnPlENMxtDr2aiJwt/n3iREjbN0HbCO 1BZwss9q229KkxHi0EE75lQeQBp3F7KnW+pB/MlL1kwUb5HsrIJJmDT4+efJPjTz49m5 3tFRqmt8567pBod0V4f3W9yAnK8I+0GNiL7uMoryNYYodDyiMv9Px0tgnZ8PUds6t674 NiitJewoywOCMXn9+su6/ZBbtrrFQ5e6aoqid0VbFqAzD+9McrpkEgCny+8JD7f3925f LN2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jqCQF3SY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si15965804pfe.204.2019.07.24.13.27.21; Wed, 24 Jul 2019 13:27:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jqCQF3SY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390193AbfGXUYy (ORCPT + 99 others); Wed, 24 Jul 2019 16:24:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:41508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389621AbfGXTkT (ORCPT ); Wed, 24 Jul 2019 15:40:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 90D4E214AF; Wed, 24 Jul 2019 19:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997218; bh=sSCbBY9onOkZJNP/mDXIjY0gRF+zB9DFt+Wo8eVglXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqCQF3SYNjM7l5hIF1wPdbrFT6uOYSEr3cT5dBY5LokaOYbt81XfveFW3gXmQ63RJ Qyw0cir3jvAW+5rn1JL0qr0nOr3q+iSLCWHar2fc9EQMUIu16gxJtp3895qoPOmruc hckltKNWsZm/337/fzShTMDgLc9v0hNbo4NRnGLY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Leon Romanovsky , Doug Ledford Subject: [PATCH 5.2 362/413] RDMA/odp: Fix missed unlock in non-blocking invalidate_start Date: Wed, 24 Jul 2019 21:20:53 +0200 Message-Id: <20190724191801.425499375@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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: Jason Gunthorpe commit 7608bf40cf2480057ec0da31456cc428791c32ef upstream. If invalidate_start returns with EAGAIN then the umem_rwsem needs to be unlocked as no invalidate_end will be called. Cc: Fixes: ca748c39ea3f ("RDMA/umem: Get rid of per_mm->notifier_count") Signed-off-by: Jason Gunthorpe Reviewed-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/umem_odp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -151,6 +151,7 @@ static int ib_umem_notifier_invalidate_r { struct ib_ucontext_per_mm *per_mm = container_of(mn, struct ib_ucontext_per_mm, mn); + int rc; if (mmu_notifier_range_blockable(range)) down_read(&per_mm->umem_rwsem); @@ -167,11 +168,14 @@ static int ib_umem_notifier_invalidate_r return 0; } - return rbt_ib_umem_for_each_in_range(&per_mm->umem_tree, range->start, - range->end, - invalidate_range_start_trampoline, - mmu_notifier_range_blockable(range), - NULL); + rc = rbt_ib_umem_for_each_in_range(&per_mm->umem_tree, range->start, + range->end, + invalidate_range_start_trampoline, + mmu_notifier_range_blockable(range), + NULL); + if (rc) + up_read(&per_mm->umem_rwsem); + return rc; } static int invalidate_range_end_trampoline(struct ib_umem_odp *item, u64 start,