Skip to content

Commit

Permalink
selftests/bpf: test_progs: Don't leak server_fd in tcp_rtt
Browse files Browse the repository at this point in the history
server_fd needs to be closed if pthread can't be created.

Fixes: 8a03222 ("selftests/bpf: test_progs: fix client/server race in tcp_rtt")
Signed-off-by: Brian Vazquez <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Stanislav Fomichev <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Brian Vazquez authored and borkmann committed Oct 1, 2019
1 parent 1bd6352 commit 86c1aea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,14 @@ void test_tcp_rtt(void)

if (CHECK_FAIL(pthread_create(&tid, NULL, server_thread,
(void *)&server_fd)))
goto close_cgroup_fd;
goto close_server_fd;

pthread_mutex_lock(&server_started_mtx);
pthread_cond_wait(&server_started, &server_started_mtx);
pthread_mutex_unlock(&server_started_mtx);

CHECK_FAIL(run_test(cgroup_fd, server_fd));
close_server_fd:
close(server_fd);
close_cgroup_fd:
close(cgroup_fd);
Expand Down

0 comments on commit 86c1aea

Please sign in to comment.