linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [PATCH] ovl: fix fd leak in ovl_flush()
Date: Tue, 26 Jan 2021 18:51:02 +0200	[thread overview]
Message-ID: <20210126165102.1017787-1-amir73il@gmail.com> (raw)

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Miklos,

This patch is against overlayfs-next which currently fails xfstests.

Thanks,
Amir.

 fs/overlayfs/file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 2ff818d5c2c9..6fa9ac682beb 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -693,12 +693,17 @@ static int ovl_flush(struct file *file, fl_owner_t id)
 	int err;
 
 	err = ovl_real_fdget(file, &real);
-	if (!err && real.file->f_op->flush) {
+	if (err)
+		return err;
+
+	if (real.file->f_op->flush) {
 		old_cred = ovl_override_creds(file_inode(file)->i_sb);
 		err = real.file->f_op->flush(real.file, id);
 		revert_creds(old_cred);
 	}
 
+	fdput(real);
+
 	return err;
 }
 
-- 
2.25.1


             reply	other threads:[~2021-01-27  4:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 16:51 Amir Goldstein [this message]
2021-01-27  5:42 ` [PATCH] ovl: fix fd leak in ovl_flush() Sargun Dhillon
2021-01-28  9:24 ` Miklos Szeredi

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20210126165102.1017787-1-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).