]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Fix a memory leak by early error exit in trace_pid_write()
authorWenwen Wang <wang6495@umn.edu>
Sat, 20 Apr 2019 02:22:59 +0000 (21:22 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 26 Apr 2019 15:45:03 +0000 (11:45 -0400)
commita9a6352fc9467746cff8bb00fe5b7f0c4db971b3
treee86c2be2969fddc37d14081504b90df8aab8c145
parent87391b8aa19256b01993563232efa4ab50385e67
tracing: Fix a memory leak by early error exit in trace_pid_write()

In trace_pid_write(), the buffer for trace parser is allocated through
kmalloc() in trace_parser_get_init(). Later on, after the buffer is used,
it is then freed through kfree() in trace_parser_put(). However, it is
possible that trace_pid_write() is terminated due to unexpected errors,
e.g., ENOMEM. In that case, the allocated buffer will not be freed, which
is a memory leak bug.

To fix this issue, free the allocated buffer when an error is encountered.

Link: http://lkml.kernel.org/r/1555726979-15633-1-git-send-email-wang6495@umn.edu
Fixes: 7d53c258c5bdb ("tracing: Use pid bitmap instead of a pid array for set_event_pid")
Cc: stable@vger.kernel.org
Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace.c