f2fs: fix null page reference in redirty_blocks
PATCH v2 1/1 f2fs: fix null page reference in redirty_blocks
From: Daeho Jeong <[email protected]>
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 <[email protected]>
Reported-by Colin Ian King <[email protected]>
Fixes 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
---
v2: changed error value and quit the page finding loop immediately
when error occurs
--- fs/f2fs/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/f2fs/file.c +4 -2
@@ -4060,8 +4060,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 );
Signature · 8 lines
2.29.2.729.g45daf8777d-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel