From 53372ea2cf848e0352bdd4fba4a664b4955cdd6e Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Tue, 1 Nov 2022 18:50:48 -0700
Subject: [PATCH 41/43] fix call bim_put in im_get_rootfs_dir

Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
 src/daemon/modules/image/image.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/daemon/modules/image/image.c b/src/daemon/modules/image/image.c
index 3c395c1f..ed7d968a 100644
--- a/src/daemon/modules/image/image.c
+++ b/src/daemon/modules/image/image.c
@@ -1774,6 +1774,8 @@ int im_container_export(const im_export_request *request)
 
 #ifdef ENABLE_OCI_IMAGE
 char *im_get_rootfs_dir(const im_get_rf_dir_request *request) {
+    char *dir = NULL;
+
     if (request->type == NULL) {
         ERROR("Missing image type");
         return NULL;
@@ -1785,8 +1787,10 @@ char *im_get_rootfs_dir(const im_get_rf_dir_request *request) {
         ERROR("Unimplemnts get rootfs dir in %s", bim->type);
         return NULL;
     }
+    dir = bim->ops->get_dir_rf();
+    bim_put(bim);
 
-    return bim->ops->get_dir_rf();
+    return dir;
 }
 #else
 char *im_get_rootfs_dir(const im_get_rf_dir_request *request) {
-- 
2.25.1

