concat() strcpy()s into the buffer returned by malloc() without checking it for NULL. If the allocation fails, the helper dereferences NULL and crashes the test. Check the allocation and exit with a failure message via ksft_exit_fail_msg(), which is how the file already reports unrecoverable errors. Signed-off-by: zhangchujun diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c index d37c068ed5fe..b70844a7a13c 100644 --- a/tools/testing/selftests/exec/execveat.c +++ b/tools/testing/selftests/exec/execveat.c @@ -138,6 +138,8 @@ static char *concat(const char *left, const char *right) { char *result = malloc(strlen(left) + strlen(right) + 1); + if (!result) + ksft_exit_fail_msg("malloc failed\n"); strcpy(result, left); strcat(result, right); return result; -- 2.50.1.windows.1