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

* Re: [PATCH] fs/squashfs: Fix memory leak in sqfs_size_nest()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2025-03-03  8:21 UTC (permalink / raw)
  To: Andrea della Porta; +Cc: Joao Marcos Costa, Thomas Petazzoni, Tom Rini, u-boot

Hi Andrea,

On 02/03/2025 at 19:29:31 +01, Andrea della Porta <andrea.porta@suse.com> wrote:

> 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>

Thanks,
Miquèl

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

* Re: [PATCH] fs/squashfs: Fix memory leak in sqfs_size_nest()
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2025-03-06 15:41 UTC (permalink / raw)
  To: Joao Marcos Costa, Thomas Petazzoni, Miquel Raynal, u-boot,
	Andrea della Porta

On Sun, 02 Mar 2025 19:29:31 +0100, Andrea della Porta wrote:

> 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.
> 
> [...]

Applied to u-boot/master, thanks!

[1/1] fs/squashfs: Fix memory leak in sqfs_size_nest()
      commit: e22b2d778106256b44e8ed32e6ad7a5d8fff3ebd
-- 
Tom



^ permalink raw reply	[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.