summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Goodbody <andrew.goodbody@linaro.org>2025-07-04 13:32:43 +0100
committerTom Rini <trini@konsulko.com>2025-07-11 10:44:29 -0600
commit36f05e622446046a93ff3a2c6958b65b85c6bffd (patch)
tree2692a36944c9482627252cae28bcbd7e27c96075
parenta7e44898b4d2484a9fd3226f44bc9b51d174f1e3 (diff)
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 <andrew.goodbody@linaro.org>
-rw-r--r--fs/ext4/ext4_write.c6
1 files 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;