From 36f05e622446046a93ff3a2c6958b65b85c6bffd Mon Sep 17 00:00:00 2001 From: Andrew Goodbody Date: Fri, 4 Jul 2025 13:32:43 +0100 Subject: [PATCH] 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 --- fs/ext4/ext4_write.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; -- 2.47.2