Skip to contentSkip to conversation

fs: ext4fs: Add initialization failure recovery path in ext4fs_write

PATCH In review Tony Dinh 2 participants 3 messages Aug 26, 2025 – Sep 10, 2025 ext4 file system

lore
Share & tools
lore

Tony Dinh

author
#0 lore raw

PATCH 1/1 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.

---
 fs/ext4/ext4_write.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/ext4_write.c +3 -1
index dd8ed40f888..5b290f0d80d 100644
@@ -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);
Signature · 1 line
2.39.5
#2 lore raw
In reply to Tony Dinh
Quoted 5 lines · Tony Dinh

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.

Applied to u-boot/next, thanks!

[1/1] fs: ext4fs: Add initialization failure recovery path in ext4fs_write

      commit: 1f8fd9d37d69ecc269943a273d3bca4c1be2384e
Signature · 1 line
Tom