public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
Date: Wed, 17 May 2017 14:07:39 +0200	[thread overview]
Message-ID: <20170517120739.2529-3-jack@suse.cz> (raw)
In-Reply-To: <20170517120739.2529-1-jack@suse.cz>

There is an off-by-one error in loop termination conditions in
ext4_find_unwritten_pgoff(). It doesn't have any visible effects but
still it is good to fix it.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index bbea2dccd584..a80f42d189e3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -502,7 +502,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
 				goto out;
 			}
 
-			if (page->index > end)
+			if (page->index >= end)
 				goto out;
 
 			lock_page(page);
@@ -550,7 +550,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
 
 		index = pvec.pages[i - 1]->index + 1;
 		pagevec_release(&pvec);
-	} while (index <= end);
+	} while (index < end);
 
 	if (whence == SEEK_HOLE && lastoff < endoff) {
 		found = 1;
-- 
2.12.0

  parent reply	other threads:[~2017-05-17 12:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 12:07 [PATCH 0/2 v2] ext4: Fix SEEK_HOLE implementation Jan Kara
2017-05-17 12:07 ` [PATCH 1/2] ext4: Fix SEEK_HOLE Jan Kara
2017-05-17 12:07 ` Jan Kara [this message]
2017-05-17 12:40 ` [PATCH 0/2 v2] ext4: Fix SEEK_HOLE implementation Eryu Guan
  -- strict thread matches above, loose matches on Subject: below --
2017-05-18 10:49 [PATCH 0/2 v3] " Jan Kara
2017-05-18 10:49 ` [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff() Jan Kara
2017-05-20  4:15   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170517120739.2529-3-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox