Skip to content

Commit

Permalink
f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block()
Browse files Browse the repository at this point in the history
[ Upstream commit 25ae837 ]

Callers may pass fio parameter with NULL value to f2fs_allocate_data_block(),
so we should make sure accessing fio's field after fio's validation check.

Fixes: f608c38 ("f2fs: clean up parameter of f2fs_allocate_data_block()")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chaseyu authored and gregkh committed May 19, 2021
1 parent 2f8dda8 commit 058b7d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -3397,12 +3397,12 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
f2fs_inode_chksum_set(sbi, page);
}

if (F2FS_IO_ALIGNED(sbi))
fio->retry = false;

if (fio) {
struct f2fs_bio_info *io;

if (F2FS_IO_ALIGNED(sbi))
fio->retry = false;

INIT_LIST_HEAD(&fio->list);
fio->in_list = true;
io = sbi->write_io[fio->type] + fio->temp;
Expand Down

0 comments on commit 058b7d4

Please sign in to comment.