[PATCH 1/2] erofs-utils: mkfs: fix memleak in error exit path
Yifan Zhao
zhaoyifan28 at huawei.com
Thu Nov 20 20:22:14 AEDT 2025
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 <zhaoyifan28 at huawei.com>
---
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
More information about the Linux-erofs
mailing list