Skip to content

Commit e194d20

Browse files
covanambrauner
authored andcommitted
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: 15858da ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao <[email protected]> Link: https://lore.kernel.org/4fb9b6fb3e0040481bacc258c44b4aab5c4df35d.1744383419.git.namcao@linutronix.de Signed-off-by: Christian Brauner <[email protected]>
1 parent 923ea4d commit e194d20

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/coredump/stackdump_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ TEST_F(coredump, stackdump)
138138
ASSERT_NE(file, NULL);
139139

140140
/* Step 4: Make sure all stack pointer values are non-zero */
141+
line = NULL;
141142
for (i = 0; -1 != getline(&line, &line_length, file); ++i) {
142143
stack = strtoull(line, NULL, 10);
143144
ASSERT_NE(stack, 0);
144145
}
146+
free(line);
145147

146148
ASSERT_EQ(i, 1 + NUM_THREAD_SPAWN);
147149

0 commit comments

Comments
 (0)