]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: Sanitize pointer prior fclose()
authorBjörn Töpel <bjorn@rivosinc.com>
Tue, 18 Mar 2025 08:16:47 +0000 (09:16 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 20 Mar 2025 17:35:07 +0000 (10:35 -0700)
commite16e64f9e076635df554f46e3ecdfbdd2f3867b2
tree89c296c6e84540cd96cb746f50295ad5aaabedfb
parent79db658ad1cba7dbdfa03212acc7e990558f45b4
selftests/bpf: Sanitize pointer prior fclose()

There are scenarios where env.{sub,}test_state->stdout_saved, can be
NULL, e.g. sometimes when the watchdog timeout kicks in, or if the
open_memstream syscall is not available.

Avoid crashing test_progs by adding an explicit NULL check prior the
fclose() call.

Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20250318081648.122523-1-bjorn@kernel.org
tools/testing/selftests/bpf/test_progs.c