Skip to content

Commit 934eed3

Browse files
Joern Engeljoshi-prasad
Joern Engel
authored andcommitted
logfs: Prevent memory corruption
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 <[email protected]> using smatch. Signed-off-by: Joern Engel <[email protected]> Signed-off-by: Prasad Joshi <[email protected]>
1 parent 9615060 commit 934eed3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/logfs/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static struct gc_candidate *get_candidate(struct super_block *sb)
367367
int i, max_dist;
368368
struct gc_candidate *cand = NULL, *this;
369369

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

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

0 commit comments

Comments
 (0)