Skip to contentSkip to conversation

f2fs: fix null page reference in redirty_blocks

PATCH Superseded Daeho Jeong 4 participants 7 messages Jan 5, 2021 – Jan 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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().

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(-)
fs/f2fs/file.c +4 -2
index 9e5275716be8..d27173c24391 100644
@@ -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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

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

Fixes 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Daeho Jeong
Quoted 22 lines · Daeho Jeong

From: Daeho Jeong <[email protected]>

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

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(-)
fs/f2fs/file.c +0 -0
index 9e5275716be8..d27173c24391 100644
@@ -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++) {

fs/f2fs/file.c static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) · line 4069

Quoted 10 lines
fs/f2fs/file.c +4 -2
 		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.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
In reply to Daeho Jeong
Quoted 2 lines

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

I suggest to choose an other imperative wording for this change description.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n89

Quoted 1 line

v2: changed error value and break the loop when error occurs

I propose to use a return statement instead of a break in the second if branch for this function implementation.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n481

Regards,
Markus

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#4 lore raw

Got it~

Thanks,

2021년 1월 5일 (화) 오후 9:06, Markus Elfring <[email protected]>님이 작성:

Quoted 26 lines
Quoted 3 lines

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

I suggest to choose an other imperative wording for this change description.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n89

Quoted 1 line

v2: changed error value and break the loop when error occurs

I propose to use a return statement instead of a break in the second if branch for this function implementation.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n481

Regards,
Markus

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#5 lore raw
In reply to Markus Elfring

Daeho,

FYI

https://www.spinics.net/lists/kernel/msg3595944.html

Quoted 27 lines · Markus Elfring
Quoted 2 lines

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

I suggest to choose an other imperative wording for this change description.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id6bbbd0e234d817938bdc52121a0f5473b3e58f5#n89

Quoted 1 line

v2: changed error value and break the loop when error occurs

I propose to use a return statement instead of a break in the second if branch for this function implementation.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id6bbbd0e234d817938bdc52121a0f5473b3e58f5#n481

Regards,
Markus

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

#6 lore raw

Thanks for the notice~

2021년 1월 6일 (수) 오전 10:04, Chao Yu <[email protected]>님이 작성:

Quoted 41 lines

Daeho,

FYI

https://www.spinics.net/lists/kernel/msg3595944.html

Quoted 21 lines · Markus Elfring
Quoted 2 lines

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

I suggest to choose an other imperative wording for this change description.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n89

Quoted 1 line

v2: changed error value and break the loop when error occurs

I propose to use a return statement instead of a break in the second if branch for this function implementation.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=36bbbd0e234d817938bdc52121a0f5473b3e58f5#n481

Regards,
Markus

Quoted 6 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel