From 7aaea7605c0e19fa7b38d7ac5dcd818942fd17a7 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 25 Feb 2014 18:27:40 -0800 Subject: jffs2: fix unbalanced locking Li Zefan reported an unbalanced locking issue, found by his internal debugging feature on runtime. The particular case he was looking at doesn't lead to a deadlock, as the structure that this lock is embedded in is freed on error. But we should straighten out the error handling. Because several callers of jffs2_do_read_inode_internal() / jffs2_do_read_inode() already handle the locking/unlocking and inode clearing at their own level, let's just push any unlocks/clearing down to the caller. This consistency is much easier to verify. Reported-by: Li Zefan Cc: David Woodhouse Cc: Artem Bityutskiy Cc: Andrew Morton Signed-off-by: Brian Norris --- fs/jffs2/fs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'fs/jffs2/fs.c') diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index fe5ea080b4ec..4cff0d54110b 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -272,12 +272,9 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) mutex_lock(&f->sem); ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); + if (ret) + goto error; - if (ret) { - mutex_unlock(&f->sem); - iget_failed(inode); - return ERR_PTR(ret); - } inode->i_mode = jemode_to_cpu(latest_node.mode); i_uid_write(inode, je16_to_cpu(latest_node.uid)); i_gid_write(inode, je16_to_cpu(latest_node.gid)); -- cgit v1.2.3-58-ga151