* [PATCH] jffs2: Make handling of erase_completion_lock consistent in jffs2_do_reserve_space()
@ 2012-11-05 18:40 Alexey Khoroshilov
2012-11-16 9:00 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2012-11-05 18:40 UTC (permalink / raw)
To: David Woodhouse
Cc: Alexey Khoroshilov, Artem Bityutskiy, linux-mtd, linux-kernel,
ldv-project
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>
---
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,
spin_unlock(&c->erase_completion_lock);
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. */
spin_lock(&c->erase_completion_lock);
+ if (ret)
+ return ret;
+
waste = jeb->free_size;
jffs2_link_node_ref(c, jeb,
(jeb->offset + c->sector_size - waste) | REF_OBSOLETE,
--
1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] jffs2: Make handling of erase_completion_lock consistent in jffs2_do_reserve_space()
2012-11-05 18:40 [PATCH] jffs2: Make handling of erase_completion_lock consistent in jffs2_do_reserve_space() Alexey Khoroshilov
@ 2012-11-16 9:00 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2012-11-16 9:00 UTC (permalink / raw)
To: Alexey Khoroshilov; +Cc: David Woodhouse, linux-mtd, linux-kernel, ldv-project
[-- Attachment #1: Type: text/plain, Size: 489 bytes --]
On Mon, 2012-11-05 at 22:40 +0400, Alexey Khoroshilov wrote:
> 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>
Pushed to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-16 9:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 18:40 [PATCH] jffs2: Make handling of erase_completion_lock consistent in jffs2_do_reserve_space() Alexey Khoroshilov
2012-11-16 9:00 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome