lkml.org 
[lkml]   [2022]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] jffs2: fix lock not released on error handling path in jffs2_flash_writev()
Date
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
\
 
 \ /
  Last update: 2022-10-19 08:53    [W:0.031 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site