fs: ext4fs: Add initialization failure recovery path in ext4fs_write

Don't invoke ext4fs_deinit() in ext4fs_write() if the failure occurs
during initialization. It would result in a crash since ext4fs_init()
has already done that.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tony Dinh
2025-09-10 10:38:56 -06:00
committed by Tom Rini
parent 371a76e845
commit 1f8fd9d37d
+3 -1
View File
@@ -877,7 +877,8 @@ int ext4fs_write(const char *fname, const char *buffer,
if (ext4fs_init() != 0) {
printf("error in File System init\n");
goto fail;
/* Skip ext4fs_deinit since ext4fs_init() already done that */
goto fail_init;
}
missing_feat = le32_to_cpu(fs->sb->feature_incompat) & ~EXT4_FEATURE_INCOMPAT_SUPP;
@@ -1050,6 +1051,7 @@ int ext4fs_write(const char *fname, const char *buffer,
return 0;
fail:
ext4fs_deinit();
fail_init:
free(inode_buffer);
free(g_parent_inode);
free(temp_ptr);