Commit 4a892c0f authored by Al Viro's avatar Al Viro

fuse_dev_ioctl(): switch to fdget()

Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 2f31fa02
...@@ -2257,30 +2257,31 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd, ...@@ -2257,30 +2257,31 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
int res; int res;
int oldfd; int oldfd;
struct fuse_dev *fud = NULL; struct fuse_dev *fud = NULL;
struct fd f;
switch (cmd) { switch (cmd) {
case FUSE_DEV_IOC_CLONE: case FUSE_DEV_IOC_CLONE:
res = -EFAULT; if (get_user(oldfd, (__u32 __user *)arg))
if (!get_user(oldfd, (__u32 __user *)arg)) { return -EFAULT;
struct file *old = fget(oldfd);
f = fdget(oldfd);
res = -EINVAL; if (!f.file)
if (old) { return -EINVAL;
/*
* Check against file->f_op because CUSE /*
* uses the same ioctl handler. * Check against file->f_op because CUSE
*/ * uses the same ioctl handler.
if (old->f_op == file->f_op) */
fud = fuse_get_dev(old); if (f.file->f_op == file->f_op)
fud = fuse_get_dev(f.file);
if (fud) {
mutex_lock(&fuse_mutex); res = -EINVAL;
res = fuse_device_clone(fud->fc, file); if (fud) {
mutex_unlock(&fuse_mutex); mutex_lock(&fuse_mutex);
} res = fuse_device_clone(fud->fc, file);
fput(old); mutex_unlock(&fuse_mutex);
}
} }
fdput(f);
break; break;
default: default:
res = -ENOTTY; res = -ENOTTY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment