Commit 789d9a53 authored by Andrii Nakryiko's avatar Andrii Nakryiko

Merge branch 'free-strdup-memory-in-selftests'

Geliang Tang says:

====================
Free strdup memory in selftests

From: Geliang Tang <tanggeliang@kylinos.cn>

Two fixes to free strdup memory in selftests to avoid memory leaks.
====================

Link: https://lore.kernel.org/r/cover.1714374022.git.tanggeliang@kylinos.cnSigned-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 19468ed5 25927d0a
......@@ -1887,10 +1887,13 @@ static int check_whitelist(struct _test *t, struct sockmap_options *opt)
while (entry) {
if ((opt->prepend && strstr(opt->prepend, entry) != 0) ||
strstr(opt->map, entry) != 0 ||
strstr(t->title, entry) != 0)
strstr(t->title, entry) != 0) {
free(ptr);
return 0;
}
entry = strtok(NULL, ",");
}
free(ptr);
return -EINVAL;
}
......@@ -1907,10 +1910,13 @@ static int check_blacklist(struct _test *t, struct sockmap_options *opt)
while (entry) {
if ((opt->prepend && strstr(opt->prepend, entry) != 0) ||
strstr(opt->map, entry) != 0 ||
strstr(t->title, entry) != 0)
strstr(t->title, entry) != 0) {
free(ptr);
return 0;
}
entry = strtok(NULL, ",");
}
free(ptr);
return -EINVAL;
}
......
......@@ -792,10 +792,13 @@ static int parse_stats(const char *stats_str, struct stat_specs *specs)
while ((next = strtok_r(state ? NULL : input, ",", &state))) {
err = parse_stat(next, specs);
if (err)
if (err) {
free(input);
return err;
}
}
free(input);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment