* [PATCH] jffs2: Fix a lock leak in jffs2_flash_writev()
@ 2026-10-26 19:54 Bart Van Assche
2026-10-27 1:41 ` Zhihao Cheng
0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2026-10-26 19:54 UTC (permalink / raw)
To: Richard Weinberger, David Woodhouse
Cc: linux-mtd, linux-kernel, Bart Van Assche
jffs2_flash_writev() write-locks c->wbuf_sem near the start of the
function. If jffs2_sum_add_kvec() fails, the function returns without
unlocking c->wbuf_sem. Fix this by unlocking c->wbuf_sem before
returning. This bug has been detected by the Clang thread-safety
analyzer.
Fixes: e631ddba5887 ("[JFFS2] Add erase block summary support (mount time improvement)")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
fs/jffs2/wbuf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 3b7803c75d58..c8fb58513783 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -904,8 +904,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
if (jffs2_sum_active()) {
int res = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to);
- if (res)
+ if (res) {
+ up_write(&c->wbuf_sem);
return res;
+ }
}
if (c->wbuf_len && ino)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] jffs2: Fix a lock leak in jffs2_flash_writev()
2026-10-26 19:54 [PATCH] jffs2: Fix a lock leak in jffs2_flash_writev() Bart Van Assche
@ 2026-10-27 1:41 ` Zhihao Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Zhihao Cheng @ 2026-10-27 1:41 UTC (permalink / raw)
To: Bart Van Assche, Richard Weinberger, David Woodhouse
Cc: linux-mtd, linux-kernel
在 2026/10/27 3:54, Bart Van Assche 写道:
> jffs2_flash_writev() write-locks c->wbuf_sem near the start of the
> function. If jffs2_sum_add_kvec() fails, the function returns without
> unlocking c->wbuf_sem. Fix this by unlocking c->wbuf_sem before
> returning. This bug has been detected by the Clang thread-safety
> analyzer.
>
> Fixes: e631ddba5887 ("[JFFS2] Add erase block summary support (mount time improvement)")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> fs/jffs2/wbuf.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
> index 3b7803c75d58..c8fb58513783 100644
> --- a/fs/jffs2/wbuf.c
> +++ b/fs/jffs2/wbuf.c
> @@ -904,8 +904,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs,
>
> if (jffs2_sum_active()) {
> int res = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to);
> - if (res)
> + if (res) {
> + up_write(&c->wbuf_sem);
> return res;
> + }
> }
>
> if (c->wbuf_len && ino)
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> .
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 1:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 19:54 [PATCH] jffs2: Fix a lock leak in jffs2_flash_writev() Bart Van Assche
2026-10-27 1:41 ` Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®