Skip to content

Commit

Permalink
sysfs: fix parent refcounting during rename and move
Browse files Browse the repository at this point in the history
Parent reference wasn't properly transferred during rename and move.
Fix it.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Tejun Heo authored and Greg Kroah-Hartman committed Jul 11, 2007
1 parent 42b37df commit 7f7cfff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ int sysfs_rename_dir(struct kobject * kobj, struct dentry *new_parent,
d_move(kobj->dentry, new_dentry);

list_del_init(&sd->s_sibling);
sysfs_get(parent_sd);
sysfs_put(sd->s_parent);
sd->s_parent = parent_sd;
list_add(&sd->s_sibling, &parent_sd->s_children);

error = 0;
Expand Down Expand Up @@ -550,6 +553,9 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent)

/* Remove from old parent's list and insert into new parent's list. */
list_del_init(&sd->s_sibling);
sysfs_get(new_parent_sd);
sysfs_put(sd->s_parent);
sd->s_parent = new_parent_sd;
list_add(&sd->s_sibling, &new_parent_sd->s_children);

out:
Expand Down

0 comments on commit 7f7cfff

Please sign in to comment.