From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gu Zheng Subject: [PATCH] f2fs: fix a potential out of range issue Date: Tue, 26 Nov 2013 16:44:16 +0800 Message-ID: <52945F60.4070005@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1VlEMF-0004nH-8R for linux-f2fs-devel@lists.sourceforge.net; Tue, 26 Nov 2013 08:50:59 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1VlEMD-0006YX-PZ for linux-f2fs-devel@lists.sourceforge.net; Tue, 26 Nov 2013 08:50:59 +0000 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Kim Cc: fsdevel , linux-kernel , f2fs Fix a potential out of range issue introduced by commit: 22fb72225a f2fs: simplify write_orphan_inodes for better readable Signed-off-by: Gu Zheng --- fs/f2fs/checkpoint.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 7fe69ff..3e62987 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -323,9 +323,9 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) memset(orphan_blk, 0, sizeof(*orphan_blk)); } - orphan_blk->ino[nentries] = cpu_to_le32(orphan->ino); + orphan_blk->ino[nentries++] = cpu_to_le32(orphan->ino); - if (nentries++ == F2FS_ORPHANS_PER_BLOCK) { + if (nentries == F2FS_ORPHANS_PER_BLOCK) { /* * an orphan block is full of 1020 entries, * then we need to flush current orphan blocks -- 1.7.7 ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754386Ab3KZIu4 (ORCPT ); Tue, 26 Nov 2013 03:50:56 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:33076 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753498Ab3KZIuv (ORCPT ); Tue, 26 Nov 2013 03:50:51 -0500 X-IronPort-AV: E=Sophos;i="4.93,773,1378828800"; d="scan'208";a="9128249" Message-ID: <52945F60.4070005@cn.fujitsu.com> Date: Tue, 26 Nov 2013 16:44:16 +0800 From: Gu Zheng User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Kim CC: f2fs , fsdevel , linux-kernel Subject: [f2fs-dev][PATCH] f2fs: fix a potential out of range issue X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/26 16:48:43, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/11/26 16:48:44, Serialize complete at 2013/11/26 16:48:44 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix a potential out of range issue introduced by commit: 22fb72225a f2fs: simplify write_orphan_inodes for better readable Signed-off-by: Gu Zheng --- fs/f2fs/checkpoint.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 7fe69ff..3e62987 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -323,9 +323,9 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) memset(orphan_blk, 0, sizeof(*orphan_blk)); } - orphan_blk->ino[nentries] = cpu_to_le32(orphan->ino); + orphan_blk->ino[nentries++] = cpu_to_le32(orphan->ino); - if (nentries++ == F2FS_ORPHANS_PER_BLOCK) { + if (nentries == F2FS_ORPHANS_PER_BLOCK) { /* * an orphan block is full of 1020 entries, * then we need to flush current orphan blocks -- 1.7.7