[PATCH] jffs2: Fix a lock leak in jffs2_flash_writev()

Zhihao Cheng chengzhihao1 at huawei.com
Mon Oct 26 18:41:35 PDT 2026


在 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 at acm.org>
> ---
>   fs/jffs2/wbuf.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Zhihao Cheng <chengzhihao1 at 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/
> .
> 




More information about the linux-mtd mailing list