This is a note to let you know that I've just added the patch titled f2fs: fix to check return value of f2fs_do_truncate_blocks() to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: f2fs-fix-to-check-return-value-of-f2fs_do_truncate_b.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit b54fdc8f979e5909ea7d8c356b1fb33b851624ef Author: Chao Yu <chao@xxxxxxxxxx> Date: Wed Apr 5 22:44:53 2023 +0800 f2fs: fix to check return value of f2fs_do_truncate_blocks() [ Upstream commit b851ee6ba3cc212641e622ebcf92b950c7bafa07 ] Otherwise, if truncation on cow_inode failed, remained data may pollute current transaction of atomic write. Cc: Daeho Jeong <daehojeong@xxxxxxxxxx> Fixes: a46bebd502fe ("f2fs: synchronize atomic write aborts") Signed-off-by: Chao Yu <chao@xxxxxxxxxx> Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c1e24da4dfec3..bf37983304a33 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2115,7 +2115,11 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) clear_inode_flag(fi->cow_inode, FI_INLINE_DATA); } else { /* Reuse the already created COW inode */ - f2fs_do_truncate_blocks(fi->cow_inode, 0, true); + ret = f2fs_do_truncate_blocks(fi->cow_inode, 0, true); + if (ret) { + f2fs_up_write(&fi->i_gc_rwsem[WRITE]); + goto out; + } } f2fs_write_inode(inode, NULL);