From: Bart Van Assche <bvanassche@acm.org>
To: Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH] jffs2: Fix a lock leak in jffs2_flash_writev()
Date: Mon, 26 Oct 2026 12:54:38 -0700 [thread overview]
Message-ID: <f7faca912d873560eff94cf729e6d75decee76bb.1793044478.git.bvanassche@acm.org> (raw)
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)
next reply other threads:[~2026-10-26 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 19:54 Bart Van Assche [this message]
2026-10-27 1:41 ` Zhihao Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7faca912d873560eff94cf729e6d75decee76bb.1793044478.git.bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®