diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2012-11-05 13:40:14 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-11-18 04:59:01 -0500 |
commit | 2cbba75a56ea78e6876b4e2547a882f10b3fe72b (patch) | |
tree | 5a3789fbc954d829605e0bd3d5fa49bedcfcbbc9 /fs/jffs2 | |
parent | d68cbdd4fb04d2b756ad53c22f36943167b16340 (diff) |
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>
Diffstat (limited to 'fs/jffs2')
-rw-r--r-- | fs/jffs2/nodemgmt.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 0c96eb52c797..03310721712f 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, | |||
417 | spin_unlock(&c->erase_completion_lock); | 417 | spin_unlock(&c->erase_completion_lock); |
418 | 418 | ||
419 | ret = jffs2_prealloc_raw_node_refs(c, jeb, 1); | 419 | ret = jffs2_prealloc_raw_node_refs(c, jeb, 1); |
420 | if (ret) | 420 | |
421 | return ret; | ||
422 | /* Just lock it again and continue. Nothing much can change because | 421 | /* Just lock it again and continue. Nothing much can change because |
423 | we hold c->alloc_sem anyway. In fact, it's not entirely clear why | 422 | we hold c->alloc_sem anyway. In fact, it's not entirely clear why |
424 | we hold c->erase_completion_lock in the majority of this function... | 423 | we hold c->erase_completion_lock in the majority of this function... |
425 | but that's a question for another (more caffeine-rich) day. */ | 424 | but that's a question for another (more caffeine-rich) day. */ |
426 | spin_lock(&c->erase_completion_lock); | 425 | spin_lock(&c->erase_completion_lock); |
427 | 426 | ||
427 | if (ret) | ||
428 | return ret; | ||
429 | |||
428 | waste = jeb->free_size; | 430 | waste = jeb->free_size; |
429 | jffs2_link_node_ref(c, jeb, | 431 | jffs2_link_node_ref(c, jeb, |
430 | (jeb->offset + c->sector_size - waste) | REF_OBSOLETE, | 432 | (jeb->offset + c->sector_size - waste) | REF_OBSOLETE, |