switch fcntl to fget_raw_light/fput_light
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
7449af1e8b
commit
545ec2c794
42
fs/fcntl.c
42
fs/fcntl.c
|
@ -442,28 +442,24 @@ static int check_fcntl_cmd(unsigned cmd)
|
||||||
SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
|
SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
|
||||||
{
|
{
|
||||||
struct file *filp;
|
struct file *filp;
|
||||||
|
int fput_needed;
|
||||||
long err = -EBADF;
|
long err = -EBADF;
|
||||||
|
|
||||||
filp = fget_raw(fd);
|
filp = fget_raw_light(fd, &fput_needed);
|
||||||
if (!filp)
|
if (!filp)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (unlikely(filp->f_mode & FMODE_PATH)) {
|
if (unlikely(filp->f_mode & FMODE_PATH)) {
|
||||||
if (!check_fcntl_cmd(cmd)) {
|
if (!check_fcntl_cmd(cmd))
|
||||||
fput(filp);
|
goto out1;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = security_file_fcntl(filp, cmd, arg);
|
err = security_file_fcntl(filp, cmd, arg);
|
||||||
if (err) {
|
if (!err)
|
||||||
fput(filp);
|
err = do_fcntl(fd, cmd, arg, filp);
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = do_fcntl(fd, cmd, arg, filp);
|
out1:
|
||||||
|
fput_light(filp, fput_needed);
|
||||||
fput(filp);
|
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -473,26 +469,21 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
|
||||||
unsigned long, arg)
|
unsigned long, arg)
|
||||||
{
|
{
|
||||||
struct file * filp;
|
struct file * filp;
|
||||||
long err;
|
long err = -EBADF;
|
||||||
|
int fput_needed;
|
||||||
|
|
||||||
err = -EBADF;
|
filp = fget_raw_light(fd, &fput_needed);
|
||||||
filp = fget_raw(fd);
|
|
||||||
if (!filp)
|
if (!filp)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (unlikely(filp->f_mode & FMODE_PATH)) {
|
if (unlikely(filp->f_mode & FMODE_PATH)) {
|
||||||
if (!check_fcntl_cmd(cmd)) {
|
if (!check_fcntl_cmd(cmd))
|
||||||
fput(filp);
|
goto out1;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = security_file_fcntl(filp, cmd, arg);
|
err = security_file_fcntl(filp, cmd, arg);
|
||||||
if (err) {
|
if (err)
|
||||||
fput(filp);
|
goto out1;
|
||||||
return err;
|
|
||||||
}
|
|
||||||
err = -EBADF;
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case F_GETLK64:
|
case F_GETLK64:
|
||||||
|
@ -507,7 +498,8 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
|
||||||
err = do_fcntl(fd, cmd, arg, filp);
|
err = do_fcntl(fd, cmd, arg, filp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fput(filp);
|
out1:
|
||||||
|
fput_light(filp, fput_needed);
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue