From 81cf4edd6aa0c4170eb0ec48a6934ef3262a920d Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Sat, 22 Oct 2022 11:48:48 +0800
Subject: [PATCH 31/43] remove mnt point if add device mapper device failed

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 .../layer_store/graphdriver/devmapper/driver_devmapper.c  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
index f4d54963..0a4e5e57 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
@@ -106,7 +106,13 @@ static int do_create(const char *id, const char *parent, const struct graphdrive
         goto out;
     }
 
-    ret = add_device(id, parent, driver->devset, create_opts->storage_opt);
+    if (add_device(id, parent, driver->devset, create_opts->storage_opt) != 0) {
+        ERROR("Failed to add device");
+        ret = -1;
+        if (util_path_remove(mnt_point_dir) != 0) {
+            ERROR("Remove path:%s failed", mnt_point_dir);
+        }
+    }
 
 out:
     free(mnt_parent_dir);
-- 
2.25.1

