Skip to content

Commit 99fc06d

Browse files
xiaosuoLinus Torvalds
authored andcommitted
procfs directory entry cleanup
Function proc_register() will assign proc_dir_operations and proc_dir_inode_operations to ent's members proc_fops and proc_iops correctly if ent is a directory. So the early assignment isn't necessary. Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 17973f5 commit 99fc06d

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

fs/proc/generic.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,6 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
530530
return -EAGAIN;
531531
dp->low_ino = i;
532532

533-
spin_lock(&proc_subdir_lock);
534-
dp->next = dir->subdir;
535-
dp->parent = dir;
536-
dir->subdir = dp;
537-
spin_unlock(&proc_subdir_lock);
538-
539533
if (S_ISDIR(dp->mode)) {
540534
if (dp->proc_iops == NULL) {
541535
dp->proc_fops = &proc_dir_operations;
@@ -551,6 +545,13 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
551545
if (dp->proc_iops == NULL)
552546
dp->proc_iops = &proc_file_inode_operations;
553547
}
548+
549+
spin_lock(&proc_subdir_lock);
550+
dp->next = dir->subdir;
551+
dp->parent = dir;
552+
dir->subdir = dp;
553+
spin_unlock(&proc_subdir_lock);
554+
554555
return 0;
555556
}
556557

@@ -653,9 +654,6 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
653654

654655
ent = proc_create(&parent, name, S_IFDIR | mode, 2);
655656
if (ent) {
656-
ent->proc_fops = &proc_dir_operations;
657-
ent->proc_iops = &proc_dir_inode_operations;
658-
659657
if (proc_register(parent, ent) < 0) {
660658
kfree(ent);
661659
ent = NULL;
@@ -690,10 +688,6 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
690688

691689
ent = proc_create(&parent,name,mode,nlink);
692690
if (ent) {
693-
if (S_ISDIR(mode)) {
694-
ent->proc_fops = &proc_dir_operations;
695-
ent->proc_iops = &proc_dir_inode_operations;
696-
}
697691
if (proc_register(parent, ent) < 0) {
698692
kfree(ent);
699693
ent = NULL;

0 commit comments

Comments
 (0)