Skip to content

Commit

Permalink
libtracecmd: Free buf_from in error path of tracecmd_compress_copy_fr…
Browse files Browse the repository at this point in the history
…om()

The failure of allocating buf_to returns without freeing buf_from.

Link: https://lore.kernel.org/linux-trace-devel/[email protected]

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217127
Reported-by: Markus Elfring <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
rostedt committed Jun 5, 2023
1 parent 6776d7a commit d7ce897
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/trace-cmd/trace-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7ce897

Please sign in to comment.