From: Andrew Goodbody Date: Fri, 4 Jul 2025 12:32:43 +0000 (+0100) Subject: fs: ext4fs: Use unwind goto to free memory on error X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36f05e622446046a93ff3a2c6958b65b85c6bffd;p=thirdparty%2Fu-boot.git fs: ext4fs: Use unwind goto to free memory on error Ensure that allocated memory is freed on error exit replace the direct return calls with 'goto fail'. This issue found by Smatch. Signed-off-by: Andrew Goodbody --- diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index d109ed6e90d..dd8ed40f888 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -877,19 +877,19 @@ int ext4fs_write(const char *fname, const char *buffer, if (ext4fs_init() != 0) { printf("error in File System init\n"); - return -1; + goto fail; } missing_feat = le32_to_cpu(fs->sb->feature_incompat) & ~EXT4_FEATURE_INCOMPAT_SUPP; if (missing_feat) { log_err("Unsupported features found %08x, not writing.\n", missing_feat); - return -1; + goto fail; } missing_feat = le32_to_cpu(fs->sb->feature_ro_compat) & ~EXT4_FEATURE_RO_COMPAT_SUPP; if (missing_feat) { log_err("Unsupported RO compat features found %08x, not writing.\n", missing_feat); - return -1; + goto fail; } inodes_per_block = fs->blksz / fs->inodesz;