Skip to content

Commit

Permalink
dm cache: destroy migration_cache if cache target registration failed
Browse files Browse the repository at this point in the history
Commit 7e6358d ("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: 7e6358d ("dm: fix various targets to dm_register_target after module __init resources created")
Cc: [email protected]
Signed-off-by: Shenghui Wang <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
shhuiw authored and snitm committed Oct 9, 2018
1 parent 0238df6 commit c7cd555
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c7cd555

Please sign in to comment.