Commit f6d90b4f authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds
Browse files

sysfs: Make sysfs_rename safe with sysfs_dirents in rbtrees.

In sysfs_rename we need to remove the optimization of not calling
sysfs_unlink_sibling and sysfs_link_sibling if the renamed parent
directory is not changing.  This optimization is no longer valid now
that sysfs dirents are stored in an rbtree sorted by name.

Move the assignment of s_ns before the call of sysfs_link_sibling.  With
no sysfs_dirent fields changing after the call of sysfs_link_sibling
this allows sysfs_link_sibling to take any of the directory entries into
account when it builds the rbtrees, and s_ns looks like a prime canidate
to be used in the rbtree in the future.
Signed-off-by: default avatarEric W. Biederman <>
Cc: Jiri Slaby <>
Cc: Greg KH <>
Cc: David Miller <>
Cc: Mikulas Patocka <>
Cc: Andrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c87d5d59
......@@ -865,15 +865,13 @@ int sysfs_rename(struct sysfs_dirent *sd,
sd->s_name = new_name;
/* Remove from old parent's list and insert into new parent's list. */
if (sd->s_parent != new_parent_sd) {
sd->s_parent = new_parent_sd;
/* Move to the appropriate place in the appropriate directories rbtree. */
sd->s_ns = new_ns;
sd->s_parent = new_parent_sd;
error = 0;
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