Skip to content

Commit

Permalink
logfs: Prevent memory corruption
Browse files Browse the repository at this point in the history
This is a bad one.  I wonder whether we were so far protected by
no_free_segments(sb) usually being smaller than LOGFS_NO_AREAS.

Found by Dan Carpenter <dan.carpenter@oracle.com> using smatch.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
  • Loading branch information
Joern Engel authored and Prasad Joshi committed Jan 28, 2012
1 parent 9615060 commit 934eed3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/logfs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static struct gc_candidate *get_candidate(struct super_block *sb)
int i, max_dist;
struct gc_candidate *cand = NULL, *this;

max_dist = min(no_free_segments(sb), LOGFS_NO_AREAS);
max_dist = min(no_free_segments(sb), LOGFS_NO_AREAS - 1);

for (i = max_dist; i >= 0; i--) {
this = first_in_list(&super->s_low_list[i]);
Expand Down

0 comments on commit 934eed3

Please sign in to comment.