lkml.org 
[lkml]   [2020]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero
Date
From: Daeho Jeong <daehojeong@google.com>

When end_addr comes to zero, it'll trigger different behaviour.
To prevent this, we need to ignore the case of that range.len is
zero in the function.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
fs/f2fs/file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 368c80f8e2a1..98b0a8dbf669 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg)
file_start_write(filp);
inode_lock(inode);

- if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) {
+ if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) ||
+ range.start >= inode->i_size) {
ret = -EINVAL;
goto err;
}

- if (range.start >= inode->i_size) {
- ret = -EINVAL;
+ if (range.len == 0)
goto err;
- }

if (inode->i_size - range.start < range.len) {
ret = -E2BIG;
--
2.27.0.383.g050319c2ae-goog
\
 
 \ /
  Last update: 2020-07-09 03:58    [W:0.045 / U:1.728 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site