From: Andrea della Porta Date: Sun, 2 Mar 2025 18:29:31 +0000 (+0100) Subject: fs/squashfs: Fix memory leak in sqfs_size_nest() X-Git-Tag: v2025.04-rc4~4 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e22b2d778106256b44e8ed32e6ad7a5d8fff3ebd;p=pandora-u-boot.git fs/squashfs: Fix memory leak in sqfs_size_nest() 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 Reviewed-by: Miquel Raynal --- diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 8fac6c6c5a9..7c364686f14 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -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;