All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-cache: destroy migration_cache if cache target registration failed
@ 2018-10-07  6:45 Shenghui Wang
  0 siblings, 0 replies; only message in thread
From: Shenghui Wang @ 2018-10-07  6:45 UTC (permalink / raw)
  To: agk, snitzer, dm-devel

Destroy migration_cache if cache target registration failed in
dm_cache_init.

Signed-off-by: Shenghui Wang <shhuiw@foxmail.com>
---
 drivers/md/dm-cache-target.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index e13d991e9fb5..c248667f549d 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -3481,17 +3481,16 @@ static struct target_type cache_target = {
 
 static int __init dm_cache_init(void)
 {
-	int r;
+	int r = -ENOMEM;
 
 	migration_cache = KMEM_CACHE(dm_cache_migration, 0);
-	if (!migration_cache) {
-		dm_unregister_target(&cache_target);
-		return -ENOMEM;
-	}
+	if (!migration_cache)
+		return r;
 
 	r = dm_register_target(&cache_target);
 	if (r) {
 		DMERR("cache target registration failed: %d", r);
+		kmem_cache_destroy(migration_cache);
 		return r;
 	}
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-10-07  6:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-07  6:45 [PATCH] dm-cache: destroy migration_cache if cache target registration failed Shenghui Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.