[PATCH] md: Fix an unlock in an error path of lbs_store()
From: Bart Van Assche
Date: Mon Oct 26 2026 - 15:57:43 EST
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@xxxxxxx>
---
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;
}