From: Andrew Morton Cc: "Changli Gao" Cc: Alexey Dobriyan Signed-off-by: Andrew Morton --- fs/proc/generic.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff -puN fs/proc/generic.c~procfs-directory-entry-cleanup-fix fs/proc/generic.c --- a/fs/proc/generic.c~procfs-directory-entry-cleanup-fix +++ a/fs/proc/generic.c @@ -529,12 +529,6 @@ static int proc_register(struct proc_dir return -EAGAIN; dp->low_ino = i; - spin_lock(&proc_subdir_lock); - dp->next = dir->subdir; - dp->parent = dir; - dir->subdir = dp; - spin_unlock(&proc_subdir_lock); - if (S_ISDIR(dp->mode)) { if (dp->proc_iops == NULL) { dp->proc_fops = &proc_dir_operations; @@ -550,6 +544,13 @@ static int proc_register(struct proc_dir if (dp->proc_iops == NULL) dp->proc_iops = &proc_file_inode_operations; } + + spin_lock(&proc_subdir_lock); + dp->next = dir->subdir; + dp->parent = dir; + dir->subdir = dp; + spin_unlock(&proc_subdir_lock); + return 0; } _