Cleanup functions `erofs_put_super()` and `liberofs_global_exit()` are
not executed if mkfs.erofs encounts an error. Fix it.

Signed-off-by: Yifan Zhao <[email protected]>
---
 mkfs/main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 76bf843..5937027 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -2024,11 +2024,12 @@ exit:
        if (err) {
                erofs_err("\tCould not format the device : %s\n",
                          erofs_strerror(err));
-               return 1;
+               err = 1;
+       } else {
+               erofs_update_progressinfo("Build completed.\n");
+               erofs_mkfs_showsummaries();
        }
-       erofs_update_progressinfo("Build completed.\n");
-       erofs_mkfs_showsummaries();
        erofs_put_super(&g_sbi);
        liberofs_global_exit();
-       return 0;
+       return err;
 }
-- 
2.33.0


Reply via email to