summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2019-02-21 13:37:14 +0100
committerJaegeuk Kim <jaegeuk@kernel.org>2019-03-13 02:59:18 +0100
commit6492a335fd8084fa894beb0c4182de439a12e8d5 (patch)
tree3ac0d440ed615323848f16b7c37f08baf94c80a9
parentf2fs: make fault injection covering __submit_flush_wait() (diff)
downloadlinux-6492a335fd8084fa894beb0c4182de439a12e8d5.tar.xz
linux-6492a335fd8084fa894beb0c4182de439a12e8d5.zip
f2fs: fix encrypted page memory leak
For IPU path of f2fs_do_write_data_page(), in its error path, we need to release encrypted page and fscrypt context, otherwise it will cause memory leak. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/data.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 65c9586b2952..3f3becd46362 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1861,8 +1861,13 @@ got_it:
if (fio->need_lock == LOCK_REQ)
f2fs_unlock_op(fio->sbi);
err = f2fs_inplace_write_data(fio);
- if (err && PageWriteback(page))
- end_page_writeback(page);
+ if (err) {
+ if (f2fs_encrypted_file(inode))
+ fscrypt_pullback_bio_page(&fio->encrypted_page,
+ true);
+ if (PageWriteback(page))
+ end_page_writeback(page);
+ }
trace_f2fs_do_write_data_page(fio->page, IPU);
set_inode_flag(inode, FI_UPDATE_WRITE);
return err;