mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
dm cache: destroy migration_cache if cache target registration failed
commitc7cd55504aupstream. Commit7e6358d244("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:7e6358d244("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8d2f62cb2d
commit
6c8faa19e9
@@ -3571,14 +3571,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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user