Linux-Fsdevel Archive on
help / color / mirror / Atom feed
From: Shuah Khan <>
Cc: Shuah Khan <>,,
Subject: [PATCH v3 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd()
Date: Wed, 13 May 2020 17:33:21 -0600	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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 <>
 fs/exec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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);
 	return ret;

  parent reply	other threads:[~2020-05-13 23:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 23:33 [PATCH v3 0/2] fs: avoid fdput() after failed fdget() Shuah Khan
2020-05-13 23:33 ` [PATCH v3 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range() Shuah Khan
2020-05-15 16:12   ` Luis Chamberlain
2020-05-13 23:33 ` Shuah Khan [this message]
2020-05-15 19:22   ` [PATCH v3 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd() Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v3 2/2] fs: avoid fdput() after failed fdget() in kernel_read_file_from_fd()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).