Skip to content

Commit 281a6ef

Browse files
Bala-Vignesh-Reddygregkh
authored andcommitted
selftests: arm64: Check fread return value in exec_target
[ Upstream commit a679e56 ] Fix -Wunused-result warning generated when compiled with gcc 13.3.0, by checking fread's return value and handling errors, preventing potential failures when reading from stdin. Fixes compiler warning: warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result] Fixes: 806a15b ("kselftests/arm64: add PAuth test for whether exec() changes keys") Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com> Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f55dfbd commit 281a6ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/testing/selftests/arm64/pauth/exec_target.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ int main(void)
1313
unsigned long hwcaps;
1414
size_t val;
1515

16-
fread(&val, sizeof(size_t), 1, stdin);
16+
size_t size = fread(&val, sizeof(size_t), 1, stdin);
17+
18+
if (size != 1) {
19+
fprintf(stderr, "Could not read input from stdin\n");
20+
return EXIT_FAILURE;
21+
}
1722

1823
/* don't try to execute illegal (unimplemented) instructions) caller
1924
* should have checked this and keep worker simple

0 commit comments

Comments
 (0)