* [PATCH] jffs2: unlock f->sem on error in jffs2_new_inode()
@ 2013-12-18 2:14 Wang Nan
2013-12-18 2:39 ` Li Zefan
0 siblings, 1 reply; 2+ messages in thread
From: Wang Nan @ 2013-12-18 2:14 UTC (permalink / raw)
To: linux-kernel; +Cc: hui.geng, Wang Guoli, stable
From: Wang Guoli <andy.wangguoli@huawei.com>
If jffs2_new_inode() succeeds, it returns with f->sem held, and
the caller is responsible for releasing the lock. If it fails,
it still returns with the lock held, but the caller won't release
the lock, which will lead to deadlock.
Fix it by releasing the lock in jffs2_new_inode() on error.
Cc: <stable@vger.kernel.org> # 2.6.34+
Signed-off-by: Wang Guoli <andy.wangguoli@huawei.com>
---
fs/jffs2/fs.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 09b3ed4..2b91675 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -456,12 +456,14 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
The umask is only applied if there's no default ACL */
ret = jffs2_init_acl_pre(dir_i, inode, &mode);
if (ret) {
- make_bad_inode(inode);
- iput(inode);
- return ERR_PTR(ret);
+ mutex_unlock(&f->sem);
+ make_bad_inode(inode);
+ iput(inode);
+ return ERR_PTR(ret);
}
ret = jffs2_do_new_inode (c, f, mode, ri);
if (ret) {
+ mutex_unlock(&f->sem);
make_bad_inode(inode);
iput(inode);
return ERR_PTR(ret);
@@ -478,6 +480,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
inode->i_size = 0;
if (insert_inode_locked(inode) < 0) {
+ mutex_unlock(&f->sem);
make_bad_inode(inode);
iput(inode);
return ERR_PTR(-EINVAL);
--
1.8.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] jffs2: unlock f->sem on error in jffs2_new_inode()
2013-12-18 2:14 [PATCH] jffs2: unlock f->sem on error in jffs2_new_inode() Wang Nan
@ 2013-12-18 2:39 ` Li Zefan
0 siblings, 0 replies; 2+ messages in thread
From: Li Zefan @ 2013-12-18 2:39 UTC (permalink / raw)
To: Wang Nan; +Cc: linux-kernel, hui.geng, Wang Guoli, stable
The patch should be sent to jffs2 mainling list, which is
linux-mtd@lists.infradead.org.
It's not needed to cc stable mailing list. Actually I think it's
better not to.
On 2013/12/18 10:14, Wang Nan wrote:
> From: Wang Guoli <andy.wangguoli@huawei.com>
>
> If jffs2_new_inode() succeeds, it returns with f->sem held, and
> the caller is responsible for releasing the lock. If it fails,
> it still returns with the lock held, but the caller won't release
> the lock, which will lead to deadlock.
>
> Fix it by releasing the lock in jffs2_new_inode() on error.
>
> Cc: <stable@vger.kernel.org> # 2.6.34+
> Signed-off-by: Wang Guoli <andy.wangguoli@huawei.com>
You should also sign the patch.
> ---
> fs/jffs2/fs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-18 2:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 2:14 [PATCH] jffs2: unlock f->sem on error in jffs2_new_inode() Wang Nan
2013-12-18 2:39 ` Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).