]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm: add missing unlock on in dm_keyslot_evict()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 30 Apr 2025 08:05:54 +0000 (11:05 +0300)
committerMikulas Patocka <mpatocka@redhat.com>
Wed, 30 Apr 2025 16:17:43 +0000 (18:17 +0200)
We need to call dm_put_live_table() even if dm_get_live_table() returns
NULL.

Fixes: 9355a9eb21a5 ("dm: support key eviction from keyslot managers of underlying devices")
Cc: stable@vger.kernel.org # v5.12+
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-table.c

index 9e175c5e0634b49b990436898f63c2b1e696febb..31d67a1a91dd60532d447674ee0511dd40f55cea 100644 (file)
@@ -1173,7 +1173,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile,
 
        t = dm_get_live_table(md, &srcu_idx);
        if (!t)
-               return 0;
+               goto put_live_table;
 
        for (unsigned int i = 0; i < t->num_targets; i++) {
                struct dm_target *ti = dm_table_get_target(t, i);
@@ -1184,6 +1184,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile,
                                          (void *)key);
        }
 
+put_live_table:
        dm_put_live_table(md, srcu_idx);
        return 0;
 }