All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/squashfs: Fix memory leak in sqfs_size_nest()
@ 2025-03-02 18:29 Andrea della Porta
  2025-03-03  8:21 ` Miquel Raynal
  2025-03-06 15:41 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Andrea della Porta @ 2025-03-02 18:29 UTC (permalink / raw)
  To: Joao Marcos Costa, Thomas Petazzoni, Miquel Raynal, Tom Rini,
	u-boot
  Cc: Andrea della Porta

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>
---
 fs/squashfs/sqfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index b9314019b1..ac5b1cda3e 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -1700,7 +1700,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;
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-06 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-02 18:29 [PATCH] fs/squashfs: Fix memory leak in sqfs_size_nest() Andrea della Porta
2025-03-03  8:21 ` Miquel Raynal
2025-03-06 15:41 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.