]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: Improve task local data documentation and fix potential memory leak
authorAmery Hung <ameryhung@gmail.com>
Tue, 31 Mar 2026 21:35:55 +0000 (14:35 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 2 Apr 2026 22:11:08 +0000 (15:11 -0700)
commit63f5156a9c3e85ecfcc0127df6069cd7baa7eeb0
tree371e33ce55eb534b8d467ae5612c202e31608a0f
parent0b481a6915ed649f12ae0a9625206781bfdcc705
selftests/bpf: Improve task local data documentation and fix potential memory leak

If TLD_FREE_DATA_ON_THREAD_EXIT is not enabled in a translation unit
that calls __tld_create_key() first, another translation unit that
enables it will not get the auto cleanup feature as pthread key is only
created once when allocation metadata. Fix it by always try to create
the pthread key when __tld_create_key() is called.

Also improve the documentation:
- Discourage user from using different options in different translation
  units
- Specify calling tld_free() before thread exit as undefined behavior

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Link: https://lore.kernel.org/r/20260331213555.1993883-6-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/task_local_data.h