diff options
author | Daeho Jeong <daehojeong@google.com> | 2021-01-06 08:49:28 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-04 12:14:17 +0100 |
commit | 9ea33f83b151e840cba23f89e71ca37643219574 (patch) | |
tree | d2c21afe0b6292baa543b01ab132c42f6a0f1be2 /fs/f2fs | |
parent | 17bd7926849e3e8ec24842d28993d8336067ba92 (diff) | |
download | linux-rt-9ea33f83b151e840cba23f89e71ca37643219574.tar.gz |
f2fs: fix null page reference in redirty_blocks
[ Upstream commit df0736d70c4fa6ed711ba103b61880fe72bb4777 ]
By Colin's static analysis, we found out there is a null page reference
under low memory situation in redirty_blocks. I've made the page finding
loop stop immediately and return an error not to cause further memory
pressure when we run into a failure to find a page under low memory
condition.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reported-by: Colin Ian King <colin.king@canonical.com>
Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
Reviewed-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/file.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index f585545277d7..cd62b0d3369a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4043,8 +4043,10 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) for (i = 0; i < page_len; i++, redirty_idx++) { page = find_lock_page(mapping, redirty_idx); - if (!page) - ret = -ENOENT; + if (!page) { + ret = -ENOMEM; + break; + } set_page_dirty(page); f2fs_put_page(page, 1); f2fs_put_page(page, 0); |