From 5ded258d2e9a331a1fa5e3f76757fdb1e868cc8f Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Thu, 20 Oct 2022 16:17:26 +0800
Subject: [PATCH 32/43] dec device info ref in grow device fs

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 .../graphdriver/devmapper/deviceset.c         | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
index 78d8737d..4dadc336 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
@@ -2483,6 +2483,7 @@ static void cleanup_deleted_devices(struct graphdriver *driver)
         device_info = lookup_device(driver->devset, idsarray[i]);
         if (device_info == NULL || device_info->info == NULL) {
             DEBUG("devmapper: no such device with hash(%s), just skip cleanup", idsarray[i]);
+            devmapper_device_info_ref_dec(device_info);
             continue;
         }
 
@@ -2900,21 +2901,20 @@ static int grow_device_fs(struct device_set *devset, const char *hash, uint64_t
 
     if (size <= base_size) {
         return 0;
-    } else {
-        DEBUG("devmapper: new fs size is larger than old basesize, start to grow fs");
-        device_info = lookup_device(devset, hash);
-        if (device_info == NULL) {
-            ERROR("devmapper: lookup device %s failed", hash);
-            ret = -1;
-            goto out;
-        }
+    }
 
-        if (grow_fs(devset, device_info->info) != 0) {
-            ret = -1;
-            goto out;
-        }
+    DEBUG("devmapper: new fs size is larger than old basesize, start to grow fs");
+    device_info = lookup_device(devset, hash);
+    if (device_info == NULL) {
+        ERROR("devmapper: lookup device %s failed", hash);
+        return -1;
     }
-out:
+
+    if (grow_fs(devset, device_info->info) != 0) {
+        ret = -1;
+    }
+
+    devmapper_device_info_ref_dec(device_info);
     return ret;
 }
 
-- 
2.25.1

