From mboxrd@z Thu Jan 1 00:00:00 1970 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 2CB4BC433DF for ; Mon, 17 Aug 2020 19:22:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D39A2075B for ; Mon, 17 Aug 2020 19:22:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597692137; bh=6M08l+qba3w1cnpo6A4R3/eEQ9w/R/WVzannPHL4M/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=p3Yi5jPDE0q8bI3sAbAV+vkjqzryeQUMlh/mzrZbwtnMXRe3I9wB9zo9m+v9UhtJF uBCKMk46wuSM8wASBVD8kWoTzg7K37kBpBc6FYbGi52rRmh5cnpD9kgpZfJLYDTZBi O/uOOcVHaDBfyGpeU0Y9yvBp8C/juVj3b+9FUsKU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730330AbgHQTWO (ORCPT ); Mon, 17 Aug 2020 15:22:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:42560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730480AbgHQPf5 (ORCPT ); Mon, 17 Aug 2020 11:35:57 -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 5E61F20855; Mon, 17 Aug 2020 15:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678557; bh=6M08l+qba3w1cnpo6A4R3/eEQ9w/R/WVzannPHL4M/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbXSUowDDmHugAcuoOlB80DBFNh3kyAyde6uhN3JDBunN5VHCwOZCkPxwXC3bHoaC QR4kMbmZFZFjqutb11fYPTVmRIxV59Q98y+JGCA5MXw8Tm6nqnHNxFbfZuQuWoLT4O RY56r/HpccErFerUwHffT3Ir6f2uo2TA0BL2Dgbk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Pavel Machek (CIP)" , Andrew Morton , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Linus Torvalds , Sasha Levin Subject: [PATCH 5.8 375/464] ocfs2: fix unbalanced locking Date: Mon, 17 Aug 2020 17:15:28 +0200 Message-Id: <20200817143851.735716875@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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: Pavel Machek [ Upstream commit 57c720d4144a9c2b88105c3e8f7b0e97e4b5cc93 ] Based on what fails, function can return with nfs_sync_rwlock either locked or unlocked. That can not be right. Always return with lock unlocked on error. Fixes: 4cd9973f9ff6 ("ocfs2: avoid inode removal while nfsd is accessing it") Signed-off-by: Pavel Machek (CIP) Signed-off-by: Andrew Morton Reviewed-by: Joseph Qi Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Link: http://lkml.kernel.org/r/20200724124443.GA28164@duo.ucw.cz Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/dlmglue.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 751bc4dc74663..8e3a369086dbd 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex) status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, 0, 0); - if (status < 0) + if (status < 0) { mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status); + if (ex) + up_write(&osb->nfs_sync_rwlock); + else + up_read(&osb->nfs_sync_rwlock); + } + return status; } -- 2.25.1