Skip to contentSkip to conversation

libtracecmd: Free buf_from in error path of tracecmd_compress_copy_from()

PATCH New Steven Rostedt 1 participant 1 message Jun 2, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracecmd: Free buf_from in error path of tracecmd_compress_copy_from()

From: "Steven Rostedt (Google)" <[email protected]>

The failure of allocating buf_to returns without freeing buf_from.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217127

---
 lib/trace-cmd/trace-compress.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/trace-cmd/trace-compress.c +3 -1
index ca6e03b88e69..e550dbd4b0d5 100644
@@ -696,8 +696,10 @@ int tracecmd_compress_copy_from(struct tracecmd_compression *handle, int fd, int
 		return -1;
 
 	buf_to = malloc(csize);
-	if (!buf_to)
+	if (!buf_to) {
+		free(buf_from);
 		return -1;
+	}
 
 	/* save the initial offset and write 0 as initial chunk count */
 	offset = lseek(handle->fd, 0, SEEK_CUR);
Signature · 1 line
2.39.2