Skip to content

Commit 00feea1

Browse files
sigmanatureJaegeuk Kim
authored andcommitted
f2fs: Zero f2fs_folio_state on allocation
f2fs_folio_state is attached to folio->private and is expected to start with read_pages_pending == 0. However, the structure was allocated from ffs_entry_slab without being fully initialized, which can leave read_pages_pending with stale values. Allocate the object with __GFP_ZERO so all fields are reliably zeroed at creation time. Signed-off-by: Nanzhe Zhao <nzzhao@126.com> Reviewed-by: Barry Song <baohua@kernel.org> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent d36de29 commit 00feea1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/f2fs/data.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,8 @@ static struct f2fs_folio_state *ffs_find_or_alloc(struct folio *folio)
23992399
if (ffs)
24002400
return ffs;
24012401

2402-
ffs = f2fs_kmem_cache_alloc(ffs_entry_slab, GFP_NOIO, true, NULL);
2402+
ffs = f2fs_kmem_cache_alloc(ffs_entry_slab,
2403+
GFP_NOIO | __GFP_ZERO, true, NULL);
24032404

24042405
spin_lock_init(&ffs->state_lock);
24052406
folio_attach_private(folio, ffs);

0 commit comments

Comments
 (0)