Patchwork [3.5.y.z,extended,stable] Patch "jffs2: hold erase_completion_lock on exit" has been added to staging queue

mail settings
Submitter Herton Ronaldo Krzesinski
Date Jan. 8, 2013, 8:56 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/210499/
State New
Headers show


Herton Ronaldo Krzesinski - Jan. 8, 2013, 8:56 p.m.
This is a note to let you know that I have just added a patch titled

    jffs2: hold erase_completion_lock on exit

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see



From 99a3bbbcc6c346b74f230513962ba7779b1a0305 Mon Sep 17 00:00:00 2001
From: Alexey Khoroshilov <>
Date: Mon, 5 Nov 2012 22:40:14 +0400
Subject: [PATCH 03/27] jffs2: hold erase_completion_lock on exit

commit 2cbba75a56ea78e6876b4e2547a882f10b3fe72b upstream.

Users of jffs2_do_reserve_space() expect they still held
erase_completion_lock after call to it. But there is a path
where jffs2_do_reserve_space() leaves erase_completion_lock unlocked.
The patch fixes it.

Found by Linux Driver Verification project (

Signed-off-by: Alexey Khoroshilov <>
Signed-off-by: Artem Bityutskiy <>
Signed-off-by: Herton Ronaldo Krzesinski <>
 fs/jffs2/nodemgmt.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)



diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 0c96eb5..0331072 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -417,14 +417,16 @@  static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,

 			ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
-			if (ret)
-				return ret;
 			/* Just lock it again and continue. Nothing much can change because
 			   we hold c->alloc_sem anyway. In fact, it's not entirely clear why
 			   we hold c->erase_completion_lock in the majority of this function...
 			   but that's a question for another (more caffeine-rich) day. */

+			if (ret)
+				return ret;
 			waste = jeb->free_size;
 			jffs2_link_node_ref(c, jeb,
 					    (jeb->offset + c->sector_size - waste) | REF_OBSOLETE,