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

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.cn


Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 19468ed5 25927d0a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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;
}

+4 −1
Original line number Diff line number Diff line
@@ -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;
}