summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAndrew Goodbody <[email protected]>2025-10-02 11:36:09 +0100
committerTom Rini <[email protected]>2025-10-10 14:27:49 -0600
commit87b7eaf3244e1a991404602c3422a4ce06bfae55 (patch)
treeedd050a7de09664f8dcd97a28f97c8023278a3d9 /fs
parent42b353412517ecfc9ba93dcd7f31e0e3557af413 (diff)
fs/squashfs: Ensure memory is freed by using unwind goto
Returning immediately from sqfs_read_nest is not consistent with other error checks in this function and can lead to memory leaks. Instead use the unwind goto used elsewhere to ensure that the memory is freed. This issue was found by Smatch. Signed-off-by: Andrew Goodbody <[email protected]> Acked-by: Quentin Schulz <[email protected]> Reviewed-by: Joao Marcos Costa <[email protected]>
Diffstat (limited to 'fs')
-rw-r--r--fs/squashfs/sqfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 2dcdd60f683..4d3d83b7587 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -1584,8 +1584,10 @@ static int sqfs_read_nest(const char *filename, void *buf, loff_t offset,
table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);
- if (__builtin_mul_overflow(n_blks, ctxt.cur_dev->blksz, &buf_size))
- return -EINVAL;
+ if (__builtin_mul_overflow(n_blks, ctxt.cur_dev->blksz, &buf_size)) {
+ ret = -EINVAL;
+ goto out;
+ }
fragment = malloc_cache_aligned(buf_size);