Commit 00feea1d authored by Nanzhe Zhao's avatar Nanzhe Zhao Committed by Jaegeuk Kim
Browse files

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: default avatarNanzhe Zhao <nzzhao@126.com>
Reviewed-by: default avatarBarry Song <baohua@kernel.org>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent d36de29f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2399,7 +2399,8 @@ static struct f2fs_folio_state *ffs_find_or_alloc(struct folio *folio)
	if (ffs)
		return ffs;

	ffs = f2fs_kmem_cache_alloc(ffs_entry_slab, GFP_NOIO, true, NULL);
	ffs = f2fs_kmem_cache_alloc(ffs_entry_slab,
			GFP_NOIO | __GFP_ZERO, true, NULL);

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