summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorShenghui Wang <shhuiw@foxmail.com>2018-10-07 14:45:41 +0800
committerMike Snitzer <snitzer@redhat.com>2018-10-09 13:53:03 -0400
commitc7cd55504a5b0fc826a2cd9540845979d24ae542 (patch)
tree4a9cff7ad26a5797094f792bed90ccb5695f6247 /drivers/md
parent0238df646e6224016a45505d2c111a24669ebe21 (diff)
dm cache: destroy migration_cache if cache target registration failed
Commit 7e6358d244e47 ("dm: fix various targets to dm_register_target after module __init resources created") inadvertently introduced this bug when it moved dm_register_target() after the call to KMEM_CACHE(). Fixes: 7e6358d244e47 ("dm: fix various targets to dm_register_target after module __init resources created") Cc: stable@vger.kernel.org Signed-off-by: Shenghui Wang <shhuiw@foxmail.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-cache-target.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index e13d991e9fb5..b29a8327eed1 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -3484,14 +3484,13 @@ static int __init dm_cache_init(void)
int r;
migration_cache = KMEM_CACHE(dm_cache_migration, 0);
- if (!migration_cache) {
- dm_unregister_target(&cache_target);
+ if (!migration_cache)
return -ENOMEM;
- }
r = dm_register_target(&cache_target);
if (r) {
DMERR("cache target registration failed: %d", r);
+ kmem_cache_destroy(migration_cache);
return r;
}