Skip to content

Commit f6ef7b7

Browse files
Christoph HellwigAl Viro
authored andcommitted
proc: remove a level of indentation in proc_get_inode
Just return early on inode allocation failure. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 9123e3a commit f6ef7b7

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

fs/proc/inode.c

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -619,42 +619,44 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
619619
{
620620
struct inode *inode = new_inode(sb);
621621

622-
if (inode) {
623-
inode->i_ino = de->low_ino;
624-
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
625-
PROC_I(inode)->pde = de;
626-
627-
if (is_empty_pde(de)) {
628-
make_empty_dir_inode(inode);
629-
return inode;
630-
}
631-
if (de->mode) {
632-
inode->i_mode = de->mode;
633-
inode->i_uid = de->uid;
634-
inode->i_gid = de->gid;
635-
}
636-
if (de->size)
637-
inode->i_size = de->size;
638-
if (de->nlink)
639-
set_nlink(inode, de->nlink);
640-
641-
if (S_ISREG(inode->i_mode)) {
642-
inode->i_op = de->proc_iops;
643-
inode->i_fop = &proc_reg_file_ops;
622+
if (!inode) {
623+
pde_put(de);
624+
return NULL;
625+
}
626+
627+
inode->i_ino = de->low_ino;
628+
inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
629+
PROC_I(inode)->pde = de;
630+
if (is_empty_pde(de)) {
631+
make_empty_dir_inode(inode);
632+
return inode;
633+
}
634+
635+
if (de->mode) {
636+
inode->i_mode = de->mode;
637+
inode->i_uid = de->uid;
638+
inode->i_gid = de->gid;
639+
}
640+
if (de->size)
641+
inode->i_size = de->size;
642+
if (de->nlink)
643+
set_nlink(inode, de->nlink);
644+
645+
if (S_ISREG(inode->i_mode)) {
646+
inode->i_op = de->proc_iops;
647+
inode->i_fop = &proc_reg_file_ops;
644648
#ifdef CONFIG_COMPAT
645-
if (!de->proc_ops->proc_compat_ioctl) {
646-
inode->i_fop = &proc_reg_file_ops_no_compat;
647-
}
649+
if (!de->proc_ops->proc_compat_ioctl)
650+
inode->i_fop = &proc_reg_file_ops_no_compat;
648651
#endif
649-
} else if (S_ISDIR(inode->i_mode)) {
650-
inode->i_op = de->proc_iops;
651-
inode->i_fop = de->proc_dir_ops;
652-
} else if (S_ISLNK(inode->i_mode)) {
653-
inode->i_op = de->proc_iops;
654-
inode->i_fop = NULL;
655-
} else
656-
BUG();
657-
} else
658-
pde_put(de);
652+
} else if (S_ISDIR(inode->i_mode)) {
653+
inode->i_op = de->proc_iops;
654+
inode->i_fop = de->proc_dir_ops;
655+
} else if (S_ISLNK(inode->i_mode)) {
656+
inode->i_op = de->proc_iops;
657+
inode->i_fop = NULL;
658+
} else {
659+
BUG();
660+
}
659661
return inode;
660662
}

0 commit comments

Comments
 (0)