diff options
author | Tejun Heo <htejun@gmail.com> | 2008-01-15 22:10:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-01-16 12:54:03 -0500 |
commit | 456ef1553cb2b06729d64c1d1f0f2bda34e9b201 (patch) | |
tree | 4ad211cbaff6056d9f1c9aded2d24e83b1641c31 /fs | |
parent | e49452c67703d3647467d65275fb893589384fed (diff) |
sysfs: fix bugs in sysfs_rename/move_dir()
sysfs_rename/move_dir() have the following bugs.
- On dentry lookup failure, kfree() is called on ERR_PTR() value.
- sysfs_move_dir() has an extra dput() on success path.
Fix them.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/sysfs/dir.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index b197016bbfbe..f281cc6584b0 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -783,6 +783,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) | |||
783 | old_dentry = sysfs_get_dentry(sd); | 783 | old_dentry = sysfs_get_dentry(sd); |
784 | if (IS_ERR(old_dentry)) { | 784 | if (IS_ERR(old_dentry)) { |
785 | error = PTR_ERR(old_dentry); | 785 | error = PTR_ERR(old_dentry); |
786 | old_dentry = NULL; | ||
786 | goto out; | 787 | goto out; |
787 | } | 788 | } |
788 | 789 | ||
@@ -850,6 +851,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) | |||
850 | old_dentry = sysfs_get_dentry(sd); | 851 | old_dentry = sysfs_get_dentry(sd); |
851 | if (IS_ERR(old_dentry)) { | 852 | if (IS_ERR(old_dentry)) { |
852 | error = PTR_ERR(old_dentry); | 853 | error = PTR_ERR(old_dentry); |
854 | old_dentry = NULL; | ||
853 | goto out; | 855 | goto out; |
854 | } | 856 | } |
855 | old_parent = old_dentry->d_parent; | 857 | old_parent = old_dentry->d_parent; |
@@ -857,6 +859,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj) | |||
857 | new_parent = sysfs_get_dentry(new_parent_sd); | 859 | new_parent = sysfs_get_dentry(new_parent_sd); |
858 | if (IS_ERR(new_parent)) { | 860 | if (IS_ERR(new_parent)) { |
859 | error = PTR_ERR(new_parent); | 861 | error = PTR_ERR(new_parent); |
862 | new_parent = NULL; | ||
860 | goto out; | 863 | goto out; |
861 | } | 864 | } |
862 | 865 | ||
@@ -880,7 +883,6 @@ again: | |||
880 | error = 0; | 883 | error = 0; |
881 | d_add(new_dentry, NULL); | 884 | d_add(new_dentry, NULL); |
882 | d_move(old_dentry, new_dentry); | 885 | d_move(old_dentry, new_dentry); |
883 | dput(new_dentry); | ||
884 | 886 | ||
885 | /* Remove from old parent's list and insert into new parent's list. */ | 887 | /* Remove from old parent's list and insert into new parent's list. */ |
886 | sysfs_unlink_sibling(sd); | 888 | sysfs_unlink_sibling(sd); |