From bc29124b1bf90eae7e9539bcafeb109e4df821ac Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Tue, 10 Oct 2023 14:04:32 -0400 Subject: [PATCH] Ensure we call fput when cloning fails due to different devices. Right now, zpl_ioctl_ficlone and zpl_ioctl_ficlonerange do not call put on the src fd if the source and destination are on two different devices. This leaves the source file held open in this case. Reviewed-by: Kay Pedersen Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Daniel Berlin Closes #15386 --- module/os/linux/zfs/zpl_file_range.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/os/linux/zfs/zpl_file_range.c b/module/os/linux/zfs/zpl_file_range.c index 2abbf44df5..c47fe99dac 100644 --- a/module/os/linux/zfs/zpl_file_range.c +++ b/module/os/linux/zfs/zpl_file_range.c @@ -202,8 +202,10 @@ zpl_ioctl_ficlone(struct file *dst_file, void *arg) if (src_file == NULL) return (-EBADF); - if (dst_file->f_op != src_file->f_op) + if (dst_file->f_op != src_file->f_op) { + fput(src_file); return (-EXDEV); + } size_t len = i_size_read(file_inode(src_file)); @@ -237,8 +239,10 @@ zpl_ioctl_ficlonerange(struct file *dst_file, void __user *arg) if (src_file == NULL) return (-EBADF); - if (dst_file->f_op != src_file->f_op) + if (dst_file->f_op != src_file->f_op) { + fput(src_file); return (-EXDEV); + } size_t len = fcr.fcr_src_length; if (len == 0)