Message ID | 62659de2dbf32e8c05cff7fe09f6efd24cfaf445.1589411496.git.skhan@linuxfoundation.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fs: avoid fdput() after failed fdget() | expand |
On Wed, 2020-05-13 at 17:33 -0600, Shuah Khan wrote: > Fix kernel_read_file_from_fd() 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 introduced in a commit that added kernel_read_file_from_fd() as > a wrapper for the VFS common kernel_read_file(). > > Fixes: b844f0ecbc56 ("vfs: define kernel_copy_file_from_fd()") > Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Thanks, Shuah. Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
diff --git a/fs/exec.c b/fs/exec.c index 06b4c550af5d..16a3d3192d6a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1015,14 +1015,14 @@ int kernel_read_file_from_fd(int fd, void **buf, loff_t *size, loff_t max_size, enum kernel_read_file_id id) { struct fd f = fdget(fd); - int ret = -EBADF; + int ret; if (!f.file) - goto out; + return -EBADF; ret = kernel_read_file(f.file, buf, size, max_size, id); -out: fdput(f); + return ret; } EXPORT_SYMBOL_GPL(kernel_read_file_from_fd);
Fix kernel_read_file_from_fd() 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 introduced in a commit that added kernel_read_file_from_fd() as a wrapper for the VFS common kernel_read_file(). Fixes: b844f0ecbc56 ("vfs: define kernel_copy_file_from_fd()") Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> --- fs/exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)