* [PATCH] jffs2: fix lock not released on error handling path in jffs2_flash_writev()
@ 2022-10-19 7:54 Li Zetao
0 siblings, 0 replies; only message in thread
From: Li Zetao @ 2022-10-19 7:54 UTC (permalink / raw)
To: dwmw2, richard
Cc: lizetao1, miquel.raynal, kernel, tglx, linux-mtd, linux-kernel
When jffs2_sum_add_kvec() returns an error in jffs2_flash_writev(), the
write lock will not be released, resulting in a deadlock.
Fix it by releasing the write lock on error handling path.
Fixes: dcb0932884b8 ("[JFFS2] Simplify writebuffer handling")
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
fs/jffs2/wbuf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 4061e0ba7010..ba3e9f4ba1d8 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -903,9 +903,9 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
*retlen = donelen;
if (jffs2_sum_active()) {
- int res = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to);
- if (res)
- return res;
+ ret = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to);
+ if (ret)
+ goto outsum;
}
if (c->wbuf_len && ino)
@@ -930,6 +930,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
outerr:
*retlen = 0;
+
+outsum:
up_write(&c->wbuf_sem);
return ret;
}
--
2.31.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-19 6:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 7:54 [PATCH] jffs2: fix lock not released on error handling path in jffs2_flash_writev() Li Zetao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).