Commit c7cd5550 authored by Shenghui Wang's avatar Shenghui Wang Committed by Mike Snitzer

dm cache: destroy migration_cache if cache target registration failed

Commit 7e6358d2 ("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: 7e6358d2 ("dm: fix various targets to dm_register_target after module __init resources created")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarShenghui Wang <shhuiw@foxmail.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 0238df64
...@@ -3484,14 +3484,13 @@ static int __init dm_cache_init(void) ...@@ -3484,14 +3484,13 @@ static int __init dm_cache_init(void)
int r; int r;
migration_cache = KMEM_CACHE(dm_cache_migration, 0); migration_cache = KMEM_CACHE(dm_cache_migration, 0);
if (!migration_cache) { if (!migration_cache)
dm_unregister_target(&cache_target);
return -ENOMEM; return -ENOMEM;
}
r = dm_register_target(&cache_target); r = dm_register_target(&cache_target);
if (r) { if (r) {
DMERR("cache target registration failed: %d", r); DMERR("cache target registration failed: %d", r);
kmem_cache_destroy(migration_cache);
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment