Skip to content

Commit

Permalink
AFS: fix interminable loop in afs_write_back_from_locked_page()
Browse files Browse the repository at this point in the history
Following bug was uncovered by compiling with '-W' flag:

  CC [M]  fs/afs/write.o
fs/afs/write.c: In function �afs_write_back_from_locked_page�:
fs/afs/write.c:398: warning: comparison of unsigned expression >= 0 is always true

Loop variable 'n' is unsigned, so wraps around happily as far as I can
see. Trival fix attached (compile tested only).

Signed-off-by: Mika Kukkonen <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dhowells authored and Linus Torvalds committed May 11, 2007
1 parent 9393e1d commit 9d577b6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
if (n == 0)
goto no_more;
if (pages[0]->index != start) {
for (n--; n >= 0; n--)
put_page(pages[n]);
do {
put_page(pages[--n]);
} while (n > 0);
goto no_more;
}

Expand Down

0 comments on commit 9d577b6

Please sign in to comment.