[PATCH] ovl: fix fd leak in ovl_flush()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---

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




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux