From: Tejun Heo Date: Wed, 13 Jun 2007 18:45:17 +0000 (+0900) Subject: sysfs: fix parent refcounting during rename and move X-Git-Tag: v2.6.23-rc1~1107^2~19 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f7cfffe60ed6271c4028ec79ae1c297b44bcb14;p=linux-2.6 sysfs: fix parent refcounting during rename and move Parent reference wasn't properly transferred during rename and move. Fix it. Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index a63d12e4be..a26e3db894 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -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 @@ again: /* 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: