* [PATCH] samples/acrn: check posix_memalign() for any error
@ 2026-10-20 3:26 Liam R. Howlett (Google)
0 siblings, 0 replies; only message in thread
From: Liam R. Howlett (Google) @ 2026-10-20 3:26 UTC (permalink / raw)
To: Fei Li; +Cc: Greg Kroah-Hartman, linux-kernel, Liam R. Howlett (Google)
posix_memalign() returns zero or a positive error number and does not set
errno. The check for a negative return is incorrect and a failed
allocation goes on to copy the guest code through guest_memory unset.
Test for a non-zero return.
Fixes: 32118bdc9471 ("virt: acrn: Replace obsolete memalign() with posix_memalign()")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
---
samples/acrn/vm-sample.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/samples/acrn/vm-sample.c b/samples/acrn/vm-sample.c
index c61e0f91456e0..0f98d2d75ae7c 100644
--- a/samples/acrn/vm-sample.c
+++ b/samples/acrn/vm-sample.c
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
argv = argv;
ret = posix_memalign(&guest_memory, 4096, GUEST_MEMORY_SIZE);
- if (ret < 0) {
+ if (ret) {
printf("Not enough memory!\n");
return -1;
}
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-20 3:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 3:26 [PATCH] samples/acrn: check posix_memalign() for any error Liam R. Howlett (Google)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®