Skip to content

Commit 27a4f7e

Browse files
namhyungAl Viro
authored and
Al Viro
committed
vfs: cleanup do_vfs_ioctl()
Move declaration of 'inode' to beginning of the function. Since it is referenced directly or indirectly (in case of FIFREEZE/FITHAW/ FS_IOC_FIEMAP) it's not harmful IMHO. And remove unnecessary casts using 'argp' instead. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent a44f99c commit 27a4f7e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

fs/ioctl.c

+8-13
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
548548
{
549549
int error = 0;
550550
int __user *argp = (int __user *)arg;
551+
struct inode *inode = filp->f_path.dentry->d_inode;
551552

552553
switch (cmd) {
553554
case FIOCLEX:
@@ -567,13 +568,11 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
567568
break;
568569

569570
case FIOQSIZE:
570-
if (S_ISDIR(filp->f_path.dentry->d_inode->i_mode) ||
571-
S_ISREG(filp->f_path.dentry->d_inode->i_mode) ||
572-
S_ISLNK(filp->f_path.dentry->d_inode->i_mode)) {
573-
loff_t res =
574-
inode_get_bytes(filp->f_path.dentry->d_inode);
575-
error = copy_to_user((loff_t __user *)arg, &res,
576-
sizeof(res)) ? -EFAULT : 0;
571+
if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) ||
572+
S_ISLNK(inode->i_mode)) {
573+
loff_t res = inode_get_bytes(inode);
574+
error = copy_to_user(argp, &res, sizeof(res)) ?
575+
-EFAULT : 0;
577576
} else
578577
error = -ENOTTY;
579578
break;
@@ -590,14 +589,10 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
590589
return ioctl_fiemap(filp, arg);
591590

592591
case FIGETBSZ:
593-
{
594-
struct inode *inode = filp->f_path.dentry->d_inode;
595-
int __user *p = (int __user *)arg;
596-
return put_user(inode->i_sb->s_blocksize, p);
597-
}
592+
return put_user(inode->i_sb->s_blocksize, argp);
598593

599594
default:
600-
if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
595+
if (S_ISREG(inode->i_mode))
601596
error = file_ioctl(filp, cmd, arg);
602597
else
603598
error = vfs_ioctl(filp, cmd, arg);

0 commit comments

Comments
 (0)