mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-05 05:07:47 -04:00
fdget(), more trivial conversions
all failure exits prior to fdget() leave the scope, all matching fdput() are immediately followed by leaving the scope. [xfs_ioc_commit_range() chunk moved here as well] Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
45
fs/splice.c
45
fs/splice.c
@@ -1622,27 +1622,22 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in,
|
||||
int, fd_out, loff_t __user *, off_out,
|
||||
size_t, len, unsigned int, flags)
|
||||
{
|
||||
struct fd in, out;
|
||||
ssize_t error;
|
||||
|
||||
if (unlikely(!len))
|
||||
return 0;
|
||||
|
||||
if (unlikely(flags & ~SPLICE_F_ALL))
|
||||
return -EINVAL;
|
||||
|
||||
error = -EBADF;
|
||||
in = fdget(fd_in);
|
||||
if (fd_file(in)) {
|
||||
out = fdget(fd_out);
|
||||
if (fd_file(out)) {
|
||||
error = __do_splice(fd_file(in), off_in, fd_file(out), off_out,
|
||||
CLASS(fd, in)(fd_in);
|
||||
if (fd_empty(in))
|
||||
return -EBADF;
|
||||
|
||||
CLASS(fd, out)(fd_out);
|
||||
if (fd_empty(out))
|
||||
return -EBADF;
|
||||
|
||||
return __do_splice(fd_file(in), off_in, fd_file(out), off_out,
|
||||
len, flags);
|
||||
fdput(out);
|
||||
}
|
||||
fdput(in);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1992,25 +1987,19 @@ ssize_t do_tee(struct file *in, struct file *out, size_t len,
|
||||
|
||||
SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
|
||||
{
|
||||
struct fd in, out;
|
||||
ssize_t error;
|
||||
|
||||
if (unlikely(flags & ~SPLICE_F_ALL))
|
||||
return -EINVAL;
|
||||
|
||||
if (unlikely(!len))
|
||||
return 0;
|
||||
|
||||
error = -EBADF;
|
||||
in = fdget(fdin);
|
||||
if (fd_file(in)) {
|
||||
out = fdget(fdout);
|
||||
if (fd_file(out)) {
|
||||
error = do_tee(fd_file(in), fd_file(out), len, flags);
|
||||
fdput(out);
|
||||
}
|
||||
fdput(in);
|
||||
}
|
||||
CLASS(fd, in)(fdin);
|
||||
if (fd_empty(in))
|
||||
return -EBADF;
|
||||
|
||||
return error;
|
||||
CLASS(fd, out)(fdout);
|
||||
if (fd_empty(out))
|
||||
return -EBADF;
|
||||
|
||||
return do_tee(fd_file(in), fd_file(out), len, flags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user