]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fs: ext4fs: Use unwind goto to free memory on error
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 4 Jul 2025 12:32:43 +0000 (13:32 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 11 Jul 2025 16:44:29 +0000 (10:44 -0600)
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 <andrew.goodbody@linaro.org>
fs/ext4/ext4_write.c

index d109ed6e90db07ff127644abe7648248caf06068..dd8ed40f888326d14499ec1f997e3c460287db1a 100644 (file)
@@ -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;