Skip to contentSkip to conversation

+ jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Dec 27, 2013 Journalling flash file system V2 (JFFS2)

lore
Share & tools
lore
#0 lore raw

Subject: + jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 27 Dec 2013 14:36:31 -0800

The patch titled

     Subject: jffs2: unlock f->sem on error in jffs2_new_inode()

has been added to the -mm tree. Its filename is
jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Wang Guoli <[email protected]>
Subject: jffs2: unlock f->sem on error in jffs2_new_inode()

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 Artem Bityutskiy <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Wang Guoli <[email protected]>
Cc <[email protected]> # 2.6.34+

---

 fs/jffs2/fs.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/jffs2/fs.c renamed from fs/jffs2/fs.c~jffs2-unlock-f-sem-on-error-in-jffs2_new_inode +6 -3
diff -puN fs/jffs2/fs.c~jffs2-unlock-f-sem-on-error-in-jffs2_new_inode fs/jffs2/fs.c
@@ -456,12 +456,14 @@ struct inode *jffs2_new_inode (struct in
 	   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 in
 	inode->i_size = 0;
 
 	if (insert_inode_locked(inode) < 0) {
+		mutex_unlock(&f->sem);
 		make_bad_inode(inode);
 		iput(inode);
 		return ERR_PTR(-EINVAL);

_

Patches currently in -mm which might be from [email protected] are

jffs2-unlock-f-sem-on-error-in-jffs2_new_inode.patch