The information “Memory leak: buf_from” was provided by the source code analysis tool “Cppcheck 2.10”. https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/tree/lib/trace-cmd/trace-compress.c?id=0a68daed9f58e4429c0f1e7818f7cc0634873112#n699 Memory which is referenced by the variable “buf_from” is not released so far if another memory allocation for the variable “buf_to” failed within the implementation of the function “tracecmd_compress_copy_from”.
Further data processing is performed after an allocation of a buffer instance succeeded. The variable “instance” contains a valid pointer then. But this pointer was checked again after the creation of a tracefs instance failed within the implementation of the function “allocate_instance”. https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/tree/tracecmd/trace-record.c?id=0a68daed9f58e4429c0f1e7818f7cc0634873112#n360 * I suggest to remove the redundant check. * May it be avoided to pass a null pointer to a call of the function “tracefs_instance_free”?
Fixed by https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/commit/?id=d7ce897734a9046b28866a13d12e78e9d492c72a ("libtracecmd: Free buf_from in error path of tracecmd_compress_copy_from()")