2021-01-05 04:20:52

by Daeho Jeong

[permalink] [raw]
Subject: [PATCH v2] f2fs: fix null page reference in redirty_blocks

From: Daeho Jeong <[email protected]>

Fixed null page reference when find_lock_page() fails in
redirty_blocks().

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 break the loop when error occurs
---
fs/f2fs/file.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9e5275716be8..d27173c24391 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -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);
--
2.29.2.729.g45daf8777d-goog


2021-01-05 06:08:28

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: fix null page reference in redirty_blocks

On 2021/1/5 12:16, Daeho Jeong wrote:
> From: Daeho Jeong <[email protected]>
>
> Fixed null page reference when find_lock_page() fails in
> redirty_blocks().
>
> 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")

Reviewed-by: Chao Yu <[email protected]>

Thanks,

2021-01-05 09:37:17

by Colin King

[permalink] [raw]
Subject: Re: [PATCH v2] f2fs: fix null page reference in redirty_blocks

On 05/01/2021 04:16, Daeho Jeong wrote:
> From: Daeho Jeong <[email protected]>
>
> Fixed null page reference when find_lock_page() fails in
> redirty_blocks().
>
> 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 break the loop when error occurs
> ---
> fs/f2fs/file.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 9e5275716be8..d27173c24391 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -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);
>
Thanks, looks good to me.

Reviewed-by: Colin Ian King <[email protected]>