mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 11:46:46 -04:00
perf ftrace: Fix leak in parse_filter_event
strsep() advances the pointer given to it. After the loop s is either NULL (on success) or points mid buffer (early exit if malloc fails) so the original buffer is never freed properly. Fix by adding a tmp pointer for use by strsep and free the original pointer Signed-off-by: Michail Tatas <michail.tatas@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
committed by
Namhyung Kim
parent
dbd2505061
commit
9d393ca644
@@ -1607,14 +1607,15 @@ static int parse_filter_event(const struct option *opt, const char *str,
|
||||
{
|
||||
struct list_head *head = opt->value;
|
||||
struct filter_entry *entry;
|
||||
char *s, *p;
|
||||
char *s, *p, *tmp;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
s = strdup(str);
|
||||
if (s == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
while ((p = strsep(&s, ",")) != NULL) {
|
||||
tmp = s;
|
||||
while ((p = strsep(&tmp, ",")) != NULL) {
|
||||
entry = malloc(sizeof(*entry) + strlen(p) + 1);
|
||||
if (entry == NULL)
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user