Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: fix mmap return code handling
@ 2015-11-25 12:47 Michael Holzheu
  2015-11-26 17:32 ` [PATCH v2] " Michael Holzheu
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Holzheu @ 2015-11-25 12:47 UTC (permalink / raw)
  To: Simon Horman; +Cc: stefan.roscher, kexec, Dave Young

Hi Simon,

I made a mistake in my mmap patch, sorry for that!

When mmap fails, MAP_FAILED (that is, (void *) -1) is returned. Currently
we assume that NULL is returned. Fix this and add the MAP_FAILED check.

Fixes: 95741713e790 ("kexec/s390x: use mmap instead of read for slurp_file")
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 kexec/kexec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index cf6e03d..02285fb 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -568,6 +568,8 @@ static char *slurp_file_generic(const char *filename, off_t *r_size,
 		if (use_mmap) {
 			buf = mmap(NULL, size, PROT_READ|PROT_WRITE,
 				   MAP_PRIVATE, fd, 0);
+			if (buf == MAP_FAILED)
+				buf = NULL;
 			nread = size;
 		} else {
 			buf = slurp_fd(fd, filename, size, &nread);
-- 
2.3.9


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-27  0:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 12:47 [PATCH] kexec: fix mmap return code handling Michael Holzheu
2015-11-26 17:32 ` [PATCH v2] " Michael Holzheu
2015-11-26 18:02   ` Petr Tesarik
2015-11-26 19:02     ` Michael Holzheu
2015-11-27  0:36       ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox