Re: [RFC] fix sysfs symlinks

viro
2004-04-29T15:41:09Z

On Thu, Apr 29, 2004 at 06:33:53PM +0530, Maneesh Soni wrote:

[snip]

> @@ -167,10 +175,14 @@ void sysfs_rename_dir(struct kobject * k
> parent = kobj->parent->dentry;
>
> down(&parent->d_inode->i_sem);
> -
> new_dentry = sysfs_get_dentry(parent, new_name);
> - d_move(kobj->dentry, new_dentry);
> - kobject_set_name(kobj,new_name);
> + if (!IS_ERR(new_dentry)) {
> + down_write(&sysfs_rename_sem);
> + d_move(kobj->dentry, new_dentry);
> + kobject_set_name(kobj,new_name);
> + up_write(&sysfs_rename_sem);
> + dput(new_dentry);
> + }
> up(&parent->d_inode->i_sem);
> }

I would probably lift that rwsem all way up - in front of any other locks
in sysfs_rename_dir(). Note that kobject_set_name() can very well lead to
allocations, so just to make the lock hierarchy cleaner... Another thing:
please, check that new_dentry is negative here. Other than that, I've
got no problems with the patch.