mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 00:34:52 +00:00
selftests/bpf: Free strdup memory in veristat
The strdup() function returns a pointer to a new string which is a duplicate of the string "input". Memory for the new string is obtained with malloc(), and need to be freed with free(). This patch adds these missing "free(input)" in parse_stats() to avoid memory leak in veristat.c. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/ded44f8865cd7f337f52fc5fb0a5fbed7d6bd641.1714374022.git.tanggeliang@kylinos.cn
This commit is contained in:
parent
237c522c1d
commit
25927d0a1b
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue