[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <31be6e0896eba59c06eb9d3d137b214f7220cc53.1588894359.git.skhan@linuxfoundation.org>
Date: Thu, 7 May 2020 17:57:09 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: viro@...iv.linux.org.uk, axboe@...nel.dk, zohar@...ux.vnet.ibm.com,
mcgrof@...nel.org, keescook@...omium.org
Cc: Shuah Khan <skhan@...uxfoundation.org>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range()
Fix ksys_sync_file_range() to avoid fdput() after a failed fdget().
fdput() doesn't do fput() on this file since FDPUT_FPUT isn't set
in fd.flags. Fix it anyway since failed fdget() doesn't require
a fdput().
This was introdcued in a commit to add sync_file_range() helper.
Fixes: 22f96b3808c1 ("fs: add sync_file_range() helper")
Signed-off-by: Shuah Khan <skhan@...uxfoundation.org>
---
fs/sync.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/sync.c b/fs/sync.c
index 4d1ff010bc5a..faaff835ef12 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -369,10 +369,11 @@ int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
ret = -EBADF;
f = fdget(fd);
- if (f.file)
+ if (f.file) {
ret = sync_file_range(f.file, offset, nbytes, flags);
+ fdput(f);
+ }
- fdput(f);
return ret;
}
--
2.20.1
Powered by blists - more mailing lists