summaryrefslogtreecommitdiff
path: root/ubifs-utils
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-02-22 20:27:58 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-09-25 09:08:41 +0200
commit8999ef158d26d9e7fe01c3d4989340342f9c69aa (patch)
tree93866a690c2e608f0b0cb829761af980af2495f4 /ubifs-utils
parent5d3902383683c997b5cb3f19f07184ed0be6d764 (diff)
mkfs.ubifs: Fix missed closing out_fd
Closing 'out_fd' is missed in handling paths in open_target(), fix it by adding closing operations before returning. Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils')
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index f5e2eb2..453a5c7 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -2848,12 +2848,16 @@ static int open_target(void)
if (out_fd == -1)
return sys_err_msg("cannot open the UBI volume '%s'",
output);
- if (ubi_set_property(out_fd, UBI_VOL_PROP_DIRECT_WRITE, 1))
+ if (ubi_set_property(out_fd, UBI_VOL_PROP_DIRECT_WRITE, 1)) {
+ close(out_fd);
return sys_err_msg("ubi_set_property(set direct_write) failed");
+ }
if (!yes && check_volume_empty()) {
- if (!prompt("UBI volume is not empty. Format anyways?", false))
+ if (!prompt("UBI volume is not empty. Format anyways?", false)) {
+ close(out_fd);
return err_msg("UBI volume is not empty");
+ }
}
} else {
out_fd = open(output, O_CREAT | O_RDWR | O_TRUNC,