Skip to contentSkip to conversation

f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block()

PATCH Superseded Chao Yu 1 participant 1 message Apr 1, 2021 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 f2fs: fix to avoid accessing invalid fio in f2fs_allocate_data_block()

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 f608c38c59c6 ("f2fs: clean up parameter of f2fs_allocate_data_block()")
---
 fs/f2fs/segment.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/segment.c +3 -3
index c517e689a9a3..d076ae03b5dc 100644
@@ -3417,9 +3417,6 @@ 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;
 
@@ -3429,6 +3426,9 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 		spin_lock(&io->io_lock);
 		list_add_tail(&fio->list, &io->io_list);
 		spin_unlock(&io->io_lock);
+
+		if (F2FS_IO_ALIGNED(sbi))
+			fio->retry = false;
 	}
 
 	mutex_unlock(&curseg->curseg_mutex);
Signature · 8 lines
2.29.2



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel