* [PATCH] md: Fix an unlock in an error path of lbs_store()
@ 2026-10-26 19:57 Bart Van Assche
2026-11-03 2:23 ` yu kuai
0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2026-10-26 19:57 UTC (permalink / raw)
To: Song Liu, Yu Kuai
Cc: Li Nan, Xiao Ni, linux-raid, linux-kernel, Bart Van Assche
If mddev_lock() fails, lbs_store() calls mddev_unlock() although the
reconfig_mutex is not held. Fix this by returning the mddev_lock() error
code directly. This bug has been detected by the Clang thread-safety
analyzer.
Fixes: 62ed1b582246 ("md: allow configuring logical block size")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/md/md.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ac03b99f6428..7ce527073be9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6049,11 +6049,10 @@ lbs_store(struct mddev *mddev, const char *buf, size_t len)
err = mddev_lock(mddev);
if (err)
- goto unlock;
+ return err;
err = mddev_set_logical_block_size(mddev, lbs);
-unlock:
mddev_unlock(mddev);
return err ?: len;
}
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] md: Fix an unlock in an error path of lbs_store()
2026-10-26 19:57 [PATCH] md: Fix an unlock in an error path of lbs_store() Bart Van Assche
@ 2026-11-03 2:23 ` yu kuai
0 siblings, 0 replies; 2+ messages in thread
From: yu kuai @ 2026-11-03 2:23 UTC (permalink / raw)
To: Bart Van Assche, Song Liu, yu kuai
Cc: Li Nan, Xiao Ni, linux-raid, linux-kernel
Hi,
在 2026/10/27 3:57, Bart Van Assche 写道:
> If mddev_lock() fails, lbs_store() calls mddev_unlock() although the
> reconfig_mutex is not held. Fix this by returning the mddev_lock() error
> code directly. This bug has been detected by the Clang thread-safety
> analyzer.
>
> Fixes: 62ed1b582246 ("md: allow configuring logical block size")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/md/md.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
This problem is already fixed:
[PATCH] md: fix mddev_unlock() called without holding lock in
lbs_store() - Jack Wang <https://lore.kernel.org/all/20260920103705.23191-1-jinpu.wang@ionos.com/>
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index ac03b99f6428..7ce527073be9 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6049,11 +6049,10 @@ lbs_store(struct mddev *mddev, const char *buf, size_t len)
>
> err = mddev_lock(mddev);
> if (err)
> - goto unlock;
> + return err;
>
> err = mddev_set_logical_block_size(mddev, lbs);
>
> -unlock:
> mddev_unlock(mddev);
> return err ?: len;
> }
--
Thanks,
Kuai
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-03 2:23 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:57 [PATCH] md: Fix an unlock in an error path of lbs_store() Bart Van Assche
2026-11-03 2:23 ` yu kuai
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®