fs/squashfs: Fix memory leak in sqfs_size_nest()
authorAndrea della Porta <andrea.porta@suse.com>
Sun, 2 Mar 2025 18:29:31 +0000 (19:29 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 5 Mar 2025 18:14:31 +0000 (12:14 -0600)
In case MAX_SYMLINK_NEST is reached while determining the size
on a symlink node, the function returns immediately.
This would not free the resources after the free_strings: label
causing a memory leak.

Set the ret value and just break out of the switch to fix this.

Signed-off-by: Andrea della Porta <andrea.porta@suse.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
fs/squashfs/sqfs.c

index 8fac6c6..7c36468 100644 (file)
@@ -1712,7 +1712,8 @@ static int sqfs_size_nest(const char *filename, loff_t *size)
        case SQFS_LSYMLINK_TYPE:
                if (++symlinknest == MAX_SYMLINK_NEST) {
                        *size = 0;
-                       return -ELOOP;
+                       ret = -ELOOP;
+                       break;
                }
 
                symlink = (struct squashfs_symlink_inode *)ipos;