]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
authorJan Kara <jack@suse.cz>
Mon, 22 May 2017 02:34:23 +0000 (22:34 -0400)
committerShan Hai <shan.hai@oracle.com>
Thu, 9 Nov 2017 01:51:32 +0000 (09:51 +0800)
There is an off-by-one error in loop termination conditions in
ext4_find_unwritten_pgoff() since 'end' may index a page beyond end of
desired range if 'endoff' is page aligned. It doesn't have any visible
effects but still it is good to fix it.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Orabug: 27093425

(backport upstream commit 3f1d5bad3fae983da07be01cff2fde13293bb7b9)

Signed-off-by: Shan Hai <shan.hai@oracle.com>
fs/ext4/file.c

index 9bda1f0730581d47f6d31c0e9e17807710353249..c5bc4bb05c2dc6ea528ec63ee41fcc39b95e21c2 100644 (file)
@@ -402,7 +402,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
        endoff = (loff_t)(map->m_lblk + map->m_len) << blkbits;
 
        index = startoff >> PAGE_CACHE_SHIFT;
-       end = endoff >> PAGE_CACHE_SHIFT;
+       end = (endoff - 1) >> PAGE_CACHE_SHIFT;
 
        pagevec_init(&pvec, 0);
        do {