All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix: possible memory leak in unxz()
@ 2024-10-06  7:25 Vishnu Sanal T
  2024-10-06 18:17 ` Lasse Collin
  2024-10-08  1:50 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Vishnu Sanal T @ 2024-10-06  7:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, lasse.collin, Vishnu Sanal T

Fixes possible memory leak in the function unxz() in
lib/decompress_unxz.c forgets to free the pointer 'in', when
the statement if (fill == NULL && flush == NULL) is true.

Signed-off-by: Vishnu Sanal T <t.v.s10123@gmail.com>
---
 lib/decompress_unxz.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 32138bb8ef77..8d58207ca1db 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -343,13 +343,13 @@ STATIC int INIT unxz(unsigned char *in, long in_size,
 			}
 		} while (ret == XZ_OK);
 
-		if (must_free_in)
-			free(in);
-
 		if (flush != NULL)
 			free(b.out);
 	}
 
+	if (must_free_in)
+		free(in);
+
 	if (in_used != NULL)
 		*in_used += b.in_pos;
 
-- 
2.46.2


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

end of thread, other threads:[~2024-10-08 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06  7:25 [PATCH] fix: possible memory leak in unxz() Vishnu Sanal T
2024-10-06 18:17 ` Lasse Collin
2024-10-08  1:50 ` Andrew Morton
2024-10-08 14:40   ` Lasse Collin

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.