aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorNam Cao <namcao@linutronix.de>2025-04-11 17:09:41 +0200
committerChristian Brauner <brauner@kernel.org>2025-05-02 14:28:18 +0200
commite194d2067c958827810a7a7282dff8773633ad8c (patch)
treeb73b79dc80797a523c427520b6d31b31e2d953b3
parentMerge patch series "net, pidfs: enable handing out pidfds for reaped sk->sk_peer_pid" (diff)
downloadwireguard-linux-e194d2067c958827810a7a7282dff8773633ad8c.tar.xz
wireguard-linux-e194d2067c958827810a7a7282dff8773633ad8c.zip
selftests: coredump: Properly initialize pointer
The buffer pointer "line" is not initialized. This pointer is passed to getline(). It can still work if the stack is zero-initialized, because getline() can work with a NULL pointer as buffer. But this is obviously broken. This bug shows up while running the test on a riscv64 machine. Fix it by properly initializing the pointer. Fixes: 15858da53542 ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao <namcao@linutronix.de> Link: https://lore.kernel.org/4fb9b6fb3e0040481bacc258c44b4aab5c4df35d.1744383419.git.namcao@linutronix.de Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--tools/testing/selftests/coredump/stackdump_test.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c
index 137b2364a082..c23cf95c3f6d 100644
--- a/tools/testing/selftests/coredump/stackdump_test.c
+++ b/tools/testing/selftests/coredump/stackdump_test.c
@@ -138,10 +138,12 @@ TEST_F(coredump, stackdump)
ASSERT_NE(file, NULL);
/* Step 4: Make sure all stack pointer values are non-zero */
+ line = NULL;
for (i = 0; -1 != getline(&line, &line_length, file); ++i) {
stack = strtoull(line, NULL, 10);
ASSERT_NE(stack, 0);
}
+ free(line);
ASSERT_EQ(i, 1 + NUM_THREAD_SPAWN);