* [PATCH] selftests/powerpc: Check mmap return value in inject-ra-err
@ 2026-07-09 12:49 longlong yan
0 siblings, 0 replies; only message in thread
From: longlong yan @ 2026-07-09 12:49 UTC (permalink / raw)
To: maddy, mpe
Cc: npiggin, chleroy, ganeshgr, linuxppc-dev, linux-kselftest,
longlong yan
mmap() in test_ra_error() is not checked for MAP_FAILED. On failure,
the subsequent write *paste_addr = 1 dereferences an invalid pointer
and segfaults. Add a FAIL_IF() check, consistent with the rest of the
function.
Fixes: 0f4ef8a3bf78 ("selftests/powerpc: Add test for real address error handling")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
tools/testing/selftests/powerpc/mce/inject-ra-err.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/powerpc/mce/inject-ra-err.c b/tools/testing/selftests/powerpc/mce/inject-ra-err.c
index 94323c34d9a6..0622fd814114 100644
--- a/tools/testing/selftests/powerpc/mce/inject-ra-err.c
+++ b/tools/testing/selftests/powerpc/mce/inject-ra-err.c
@@ -47,6 +47,7 @@ static int test_ra_error(void)
FAIL_IF(sigaction(SIGBUS, &act, NULL) != 0);
paste_addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0ULL);
+ FAIL_IF(paste_addr == MAP_FAILED);
/* The following assignment triggers exception */
mb();
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-10 0:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 12:49 [PATCH] selftests/powerpc: Check mmap return value in inject-ra-err longlong yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox