dm raid: fix missing reconfig_mutex unlock in raid_ctr() error paths
authorYu Kuai <yukuai3@huawei.com>
Sat, 8 Jul 2023 09:21:51 +0000 (17:21 +0800)
committerMike Snitzer <snitzer@kernel.org>
Tue, 25 Jul 2023 15:55:50 +0000 (11:55 -0400)
In the error paths 'bad_stripe_cache' and 'bad_check_reshape',
'reconfig_mutex' is still held after raid_ctr() returns.

Fixes: 9dbd1aa3a81c ("dm raid: add reshaping support to the target")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-raid.c

index 8846bf510a35e04ec25b804dc82c4392968670af..3d7366b912bfee4947015bf09c88b482813dc680 100644 (file)
@@ -3271,15 +3271,19 @@ size_check:
        /* Try to adjust the raid4/5/6 stripe cache size to the stripe size */
        if (rs_is_raid456(rs)) {
                r = rs_set_raid456_stripe_cache(rs);
-               if (r)
+               if (r) {
+                       mddev_unlock(&rs->md);
                        goto bad_stripe_cache;
+               }
        }
 
        /* Now do an early reshape check */
        if (test_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags)) {
                r = rs_check_reshape(rs);
-               if (r)
+               if (r) {
+                       mddev_unlock(&rs->md);
                        goto bad_check_reshape;
+               }
 
                /* Restore new, ctr requested layout to perform check */
                rs_config_restore(rs, &rs_layout);
@@ -3288,6 +3292,7 @@ size_check:
                        r = rs->md.pers->check_reshape(&rs->md);
                        if (r) {
                                ti->error = "Reshape check failed";
+                               mddev_unlock(&rs->md);
                                goto bad_check_reshape;
                        }
                }