Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D115C433F5 for ; Wed, 24 Nov 2021 13:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350223AbhKXNfV (ORCPT ); Wed, 24 Nov 2021 08:35:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:60710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347594AbhKXNck (ORCPT ); Wed, 24 Nov 2021 08:32:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D0F8F611BF; Wed, 24 Nov 2021 12:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637758397; bh=lzr89GUAN18tttA0+3O/es6DyB/GD0yiifspf+G/B5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUb/JKUbT1XlNUAYD5mC8T6CkVwqdx8XqD5NAH9wQnNAAD1W16hO1/L0QCRcmxhP0 WYGtobOeBpwbtrDYI/fc9itnBkhRESY9DGPQfJXPUVsickKgyRvn+MrP1jBkR3NrUS /nSFygyiCugEW0Nm9sYotM58nEt++kNPttKIwgIA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.10 056/154] f2fs: fix incorrect return value in f2fs_sanity_check_ckpt() Date: Wed, 24 Nov 2021 12:57:32 +0100 Message-Id: <20211124115704.139917114@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115702.361983534@linuxfoundation.org> References: <20211124115702.361983534@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit ca98d72141dd81f42893a9a43d7ededab3355fba ] As Pavel Machek reported in [1] This code looks quite confused: part of function returns 1 on corruption, part returns -errno. The problem is not stable-specific. [1] https://lkml.org/lkml/2021/9/19/207 Let's fix to make 'insane cp_payload case' to return 1 rater than EFSCORRUPTED, so that return value can be kept consistent for all error cases, it can avoid confusion of code logic. Fixes: 65ddf6564843 ("f2fs: fix to do sanity check for sb/cp fields correctly") Reported-by: Pavel Machek Reviewed-by: Pavel Machek Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 70b513e66af77..b7287b722e9e1 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3081,7 +3081,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) { f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)", cp_payload, nat_bits_blocks); - return -EFSCORRUPTED; + return 1; } if (unlikely(f2fs_cp_error(sbi))) { -- 2.33.0