Skip to content

Commit

Permalink
Ensure we call fput when cloning fails due to different devices.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Daniel Berlin <[email protected]>
Closes #15386
  • Loading branch information
dberlin authored Oct 10, 2023
1 parent 483ccf0 commit bc29124
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions module/os/linux/zfs/zpl_file_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bc29124

Please sign in to comment.