[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070304151659.GA19972@APFDCB5C>
Date: Mon, 5 Mar 2007 00:16:59 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: linux-kernel@...r.kernel.org, Joel Becker <joel.becker@...cle.com>
Subject: Re: [PATCH] configfs: add missing mutex_unlock()
On Sun, Mar 04, 2007 at 03:10:19PM +0100, Arnd Bergmann wrote:
> On Sunday 04 March 2007 14:38:12 Akinobu Mita wrote:
> > @@ -1168,8 +1168,10 @@ int configfs_register_subsystem(struct c
> >
> > err = -ENOMEM;
> > dentry = d_alloc(configfs_sb->s_root, &name);
> > - if (!dentry)
> > + if (!dentry) {
> > + mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
> > goto out_release;
> > + }
> >
> > d_add(dentry, NULL);
>
> This should be changed to jump to a new exit point, before the mutex_unlock
> at the end of the function. Having multiple places in the function that
> release the same lock easily leads to the kind of bug you are fixing here.
Agreed. Please see the patch below (untested).
Index: 2.6-mm/fs/configfs/dir.c
===================================================================
--- 2.6-mm.orig/fs/configfs/dir.c
+++ 2.6-mm/fs/configfs/dir.c
@@ -1169,25 +1169,26 @@ int configfs_register_subsystem(struct c
err = -ENOMEM;
dentry = d_alloc(configfs_sb->s_root, &name);
if (!dentry)
- goto out_release;
+ goto out_unlock;
d_add(dentry, NULL);
err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
- if (!err)
- dentry = NULL;
- else
- d_delete(dentry);
+ if (err)
+ goto out_d_delete;
mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
- if (dentry) {
- dput(dentry);
-out_release:
- unlink_group(group);
- configfs_release_fs();
- }
+ return 0;
+
+out_d_delete:
+ d_delete(dentry);
+ dput(dentry);
+out_unlock:
+ mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
+ unlink_group(group);
+ configfs_release_fs();
return err;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists