Skip to content

Commit

Permalink
f2fs: should put a page beyond EOF when preparing a write
Browse files Browse the repository at this point in the history
[ Upstream commit 9605f75 ]

The prepare_compress_overwrite() gets/locks a page to prepare a read, and calls
f2fs_read_multi_pages() which checks EOF first. If there's any page beyond EOF,
we unlock the page and set cc->rpages[i] = NULL, which we can't put the page
anymore. This makes page leak, so let's fix by putting that page.

Fixes: a949dc5 ("f2fs: compress: fix race condition of overwrite vs truncate")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Jaegeuk Kim authored and gregkh committed Sep 18, 2021
1 parent d04925f commit bb81085
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/f2fs/data.c
Expand Up @@ -2219,6 +2219,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
continue;
}
unlock_page(page);
if (for_write)
put_page(page);
cc->rpages[i] = NULL;
cc->nr_rpages--;
}
Expand Down

0 comments on commit bb81085

Please sign in to comment.