]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit1a79afaafd5188ab73f545f036bf6cb9cf7bbbf6
tree94a7688829ebe26f75a9d7acacd8048fd5ebf317
parentc6dd72290d02dcc6545631be8448d7a6668adcda
tracing: Fix a memory leak by early error exit in trace_pid_write()

BugLink: https://bugs.launchpad.net/bugs/1838459
commit 91862cc7867bba4ee5c8fcf0ca2f1d30427b6129 upstream.

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: f4d34a87e9c10 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
kernel/trace/trace.c