JFFS2: fix deadlock on error path
PATCH 1/1 JFFS2: fix deadlock on error path
From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] JFFS2: fix deadlock on error path
When the MTD driver returns write failure, the following deadlock occures:
We are in __jffs2_flush_wbuf(), we hold &c->wbuf_sem. Write failure. jffs2_wbuf_recover()->jffs2_reserve_space_gc()->jffs2_do_reserve_space() ->jffs2_erase_pending_blocks()->jffs2_flash_read()
and it tries to lock &c->wbuf_sem again. Deadlock.
--- fs/jffs2/erase.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/jffs2/erase.c +1 -1
@@ -333,7 +333,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl *bad_offset = ofs; - ret =jffs2_flash_read (c, ofs, readlen, &retlen, ebuf); + ret = c->mtd->read (c->mtd, ofs, readlen, &retlen, ebuf);if (ret) {printk (KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n" , ofs, ret); goto fail;
Signature · 5 lines
1.4.4.2 -- Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 6 lines · Artem Bityutskiy
From: Artem Bityutskiy <[email protected]>
Subject: [PATCH] JFFS2: fix deadlock on error pathWhen the MTD driver returns write failure, the following deadlock occures:
Quoted 8 lines
We are in
__jffs2_flush_wbuf(), we hold&c->wbuf_sem. Write failure. jffs2_wbuf_recover()->jffs2_reserve_space_gc()->jffs2_do_reserve_space() ->jffs2_erase_pending_blocks()->jffs2_flash_read()and it tries to lock
&c->wbuf_semagain. Deadlock.Reported-by Adrian Hunter <[email protected]>Signed-off-by Artem Bityutskiy <[email protected]>
David,
please, send this patch to Linus as it is critical enough.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)