diff options
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r-- | fs/proc/generic.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index fa678abc9db1..480cb1065eec 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -429,7 +429,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, | |||
429 | unsigned int ino; | 429 | unsigned int ino; |
430 | 430 | ||
431 | ino = de->low_ino; | 431 | ino = de->low_ino; |
432 | de_get(de); | 432 | pde_get(de); |
433 | spin_unlock(&proc_subdir_lock); | 433 | spin_unlock(&proc_subdir_lock); |
434 | error = -EINVAL; | 434 | error = -EINVAL; |
435 | inode = proc_get_inode(dir->i_sb, ino, de); | 435 | inode = proc_get_inode(dir->i_sb, ino, de); |
@@ -445,7 +445,7 @@ out_unlock: | |||
445 | return NULL; | 445 | return NULL; |
446 | } | 446 | } |
447 | if (de) | 447 | if (de) |
448 | de_put(de); | 448 | pde_put(de); |
449 | return ERR_PTR(error); | 449 | return ERR_PTR(error); |
450 | } | 450 | } |
451 | 451 | ||
@@ -509,17 +509,17 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, | |||
509 | struct proc_dir_entry *next; | 509 | struct proc_dir_entry *next; |
510 | 510 | ||
511 | /* filldir passes info to user space */ | 511 | /* filldir passes info to user space */ |
512 | de_get(de); | 512 | pde_get(de); |
513 | spin_unlock(&proc_subdir_lock); | 513 | spin_unlock(&proc_subdir_lock); |
514 | if (filldir(dirent, de->name, de->namelen, filp->f_pos, | 514 | if (filldir(dirent, de->name, de->namelen, filp->f_pos, |
515 | de->low_ino, de->mode >> 12) < 0) { | 515 | de->low_ino, de->mode >> 12) < 0) { |
516 | de_put(de); | 516 | pde_put(de); |
517 | goto out; | 517 | goto out; |
518 | } | 518 | } |
519 | spin_lock(&proc_subdir_lock); | 519 | spin_lock(&proc_subdir_lock); |
520 | filp->f_pos++; | 520 | filp->f_pos++; |
521 | next = de->next; | 521 | next = de->next; |
522 | de_put(de); | 522 | pde_put(de); |
523 | de = next; | 523 | de = next; |
524 | } while (de); | 524 | } while (de); |
525 | spin_unlock(&proc_subdir_lock); | 525 | spin_unlock(&proc_subdir_lock); |
@@ -763,7 +763,7 @@ out: | |||
763 | return NULL; | 763 | return NULL; |
764 | } | 764 | } |
765 | 765 | ||
766 | void free_proc_entry(struct proc_dir_entry *de) | 766 | static void free_proc_entry(struct proc_dir_entry *de) |
767 | { | 767 | { |
768 | unsigned int ino = de->low_ino; | 768 | unsigned int ino = de->low_ino; |
769 | 769 | ||
@@ -777,6 +777,12 @@ void free_proc_entry(struct proc_dir_entry *de) | |||
777 | kfree(de); | 777 | kfree(de); |
778 | } | 778 | } |
779 | 779 | ||
780 | void pde_put(struct proc_dir_entry *pde) | ||
781 | { | ||
782 | if (atomic_dec_and_test(&pde->count)) | ||
783 | free_proc_entry(pde); | ||
784 | } | ||
785 | |||
780 | /* | 786 | /* |
781 | * Remove a /proc entry and free it if it's not currently in use. | 787 | * Remove a /proc entry and free it if it's not currently in use. |
782 | */ | 788 | */ |
@@ -845,6 +851,5 @@ continue_removing: | |||
845 | WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " | 851 | WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " |
846 | "'%s/%s', leaking at least '%s'\n", __func__, | 852 | "'%s/%s', leaking at least '%s'\n", __func__, |
847 | de->parent->name, de->name, de->subdir->name); | 853 | de->parent->name, de->name, de->subdir->name); |
848 | if (atomic_dec_and_test(&de->count)) | 854 | pde_put(de); |
849 | free_proc_entry(de); | ||
850 | } | 855 | } |