From: Feng Yang <[email protected]> In test__start_subtest_with_desc, if strdup fails or an empty name is passed, the function returns early. Later, worker_main_send_subtests copies the name via strscpy, which leads to a NULL pointer dereference.
Signed-off-by: Feng Yang <[email protected]> --- tools/testing/selftests/bpf/test_progs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index ea9c887201ae..ab88268db9e2 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -1882,7 +1882,8 @@ static int worker_main_send_subtests(int sock, struct test_state *state) msg.subtest_done.num = i; - strscpy(msg.subtest_done.name, subtest_state->name, MAX_SUBTEST_NAME); + const char *name = subtest_state->name ? : ""; + strscpy(msg.subtest_done.name, name, MAX_SUBTEST_NAME); msg.subtest_done.error_cnt = subtest_state->error_cnt; msg.subtest_done.skipped = subtest_state->skipped; -- 2.43.0

