Commit 7f7cfffe authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman

sysfs: fix parent refcounting during rename and move

Parent reference wasn't properly transferred during rename and move.
Fix it.
Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 42b37df6
......@@ -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;
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment