Skip to content

Commit

Permalink
xfs: Fix off-by-in in loop termination in xfs_find_get_desired_pgoff()
Browse files Browse the repository at this point in the history
There is an off-by-one error in loop termination conditions in
xfs_find_get_desired_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>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Jan Kara authored and Darrick J. Wong committed May 25, 2017
1 parent 5375023 commit d7fd242
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ xfs_find_get_desired_pgoff(

index = startoff >> PAGE_SHIFT;
endoff = XFS_FSB_TO_B(mp, map->br_startoff + map->br_blockcount);
end = endoff >> PAGE_SHIFT;
end = (endoff - 1) >> PAGE_SHIFT;
do {
int want;
unsigned nr_pages;
Expand Down

0 comments on commit d7fd242

Please sign in to comment.