Skip to content

Commit 2cbba75

Browse files
khoroshilovdedekind
authored andcommitted
jffs2: hold erase_completion_lock on exit
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 (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Cc: stable@vger.kernel.org Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent d68cbdd commit 2cbba75

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/jffs2/nodemgmt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,16 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
417417
spin_unlock(&c->erase_completion_lock);
418418

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

427+
if (ret)
428+
return ret;
429+
428430
waste = jeb->free_size;
429431
jffs2_link_node_ref(c, jeb,
430432
(jeb->offset + c->sector_size - waste) | REF_OBSOLETE,

0 commit comments

Comments
 (0)