Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp534364pxa; Fri, 31 Jul 2020 20:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzoUI/bExsgSQ6kHepCL/knAuVqVRPfTBndS7+cfOc7rtX5HWwRnYr5uM1OP0m3UrbnE9R X-Received: by 2002:a17:906:b046:: with SMTP id bj6mr7293211ejb.349.1596252655227; Fri, 31 Jul 2020 20:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596252655; cv=none; d=google.com; s=arc-20160816; b=gZRlRLW4QpGD6HkRrOs1CVm1yIGpjehCzvt7K35zSxVAdOVqmSiW1/Y7CfRDr4Gg6F vTo2vWJQEruCnp8Zg3LLCd5rxkN846KuJdVC3bFTFUx0bIl6qqHd8acAx6JhZLXC0YZi PUZt2H1K03sOo5ThzON5cQ3xLOBh577Co5h8c2JSKa34buK3NrSKhraksTqkQul2yLX2 +5s+Th1UqHCHKUIbNi4JqThqEVBPvE9w+5CjpKNFrS+5AkRiNjkSUZxcjwcbpTe2Ix71 ANfgEey5LIJwQh62JuXP/3ZRzzRz6M22N7xX02JByxcq3LfIesoFxdRmid87oEcm38fq BH3A== 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 :message-id:date:subject:cc:to:from; bh=GuS8OepY1FtcPE1oTHd4+KFREKHxNeMgQqDLOdpQQ2I=; b=yTEUG7N5jk2zP/xMotxCJNgP8m3huWE3lOWkD1C7frYdK3waM3HJ6RElsJygL/Iv+u AymhJ7a3UtaFk0w3x9makN+D9laQRb09pW9K8zr0Zik+/vh92wzzRf2JIEkqj9JNxsEP 6w3oCe8ya6FDZnf/RWTK9Kex8aBjCD3go+5Z4vmgptEhVCudM03GOn8QZKIPoFbnB+tK 7DjoXWIQdhcbrAJGd29wULOO3C7ILPBpt3R6rkAYqSvsMjr2auhpptovFJacQ2JfXyWR cuLqRpK7hhKEUYL/xK3opcYq14yApE+fzOdGLi0pb83Rg8uwRpcEwDE3NflcJh87zxLL 245Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si7005409edi.420.2020.07.31.20.30.15; Fri, 31 Jul 2020 20:30:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728375AbgHADZM (ORCPT + 99 others); Fri, 31 Jul 2020 23:25:12 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59296 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727824AbgHADZM (ORCPT ); Fri, 31 Jul 2020 23:25:12 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D03D634FCD7D356B5745; Sat, 1 Aug 2020 11:24:59 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Sat, 1 Aug 2020 11:24:52 +0800 From: Zhihao Cheng To: , , CC: , Subject: [f2fs-dev][PATCH] f2fs: update_sit_entry: Make the judgment condition of f2fs_bug_on more intuitive Date: Sat, 1 Aug 2020 11:24:50 +0800 Message-ID: <20200801032450.3028986-1-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current judgment condition of f2fs_bug_on in function update_sit_entry(): new_vblocks >> (sizeof(unsigned short) << 3) || new_vblocks > sbi->blocks_per_seg which equivalents to: new_vblocks < 0 || new_vblocks > sbi->blocks_per_seg The latter is more intuitive. Signed-off-by: Zhihao Cheng Reported-by: Jack Qiu --- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 196f31503511..41836447418d 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2140,7 +2140,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) new_vblocks = se->valid_blocks + del; offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr); - f2fs_bug_on(sbi, (new_vblocks >> (sizeof(unsigned short) << 3) || + f2fs_bug_on(sbi, (new_vblocks < 0 || (new_vblocks > sbi->blocks_per_seg))); se->valid_blocks = new_vblocks; -- 2.25.4