Re: [PATCH] Fix 2.6.21 rfcomm lockups (2.6.21 regression)

Cornelia Huck
2007-03-05T12:40:34Z

On Sun, 04 Mar 2007 13:26:49 -0500,
Mark Lord <lkml@rtr.ca> wrote:

> The simplest fix for this bug is to prevent sysfs_move_dir()
> from self-deadlocking when (old_parent == new_parent).
>
> This patch prevents total system lockup when using rfcomm devices.
>
> Signed-off-by: Mark Lord <mlord@pobox.com>
> ---
> --- 2.6.21/fs/sysfs/dir.c 2007-03-04 13:19:00.000000000 -0500
> +++ linux/fs/sysfs/dir.c 2007-03-04 13:20:45.000000000 -0500
> @@ -431,6 +431,8 @@
> new_parent_dentry = new_parent ?
> new_parent->dentry : sysfs_mount->mnt_sb->s_root;
>
> + if (old_parent_dentry->d_inode == new_parent_dentry->d_inode)
> + return 0; /* nothing to move */
> again:
> mutex_lock(&old_parent_dentry->d_inode->i_mutex);
> if (!mutex_trylock(&new_parent_dentry->d_inode->i_mutex)) {

Hm, never thought that someone might call the moving functions with
old_parent == new_parent, sorry about that. It should be safe to
return success here, we add only a bit of overhead with some driver
model juggling and emitting a not needed uevent.

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>