qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Jürg Billeter" <j@bitron.ch>
To: qemu-devel@nongnu.org
Cc: "Jürg Billeter" <j@bitron.ch>, "Riku Voipio" <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH] linux-user: Do not ignore mmap failure from host
Date: Sat, 29 Jun 2013 11:41:32 +0200	[thread overview]
Message-ID: <1372498892-23676-1-git-send-email-j@bitron.ch> (raw)

File mapping may fail with EACCES.

Signed-off-by: Jürg Billeter <j@bitron.ch>
---
 linux-user/mmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index b412e3f..de22197 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -483,6 +483,10 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         if (!(flags & MAP_ANONYMOUS)) {
             p = mmap(g2h(start), len, prot,
                      flags | MAP_FIXED, fd, host_offset);
+            if (p == MAP_FAILED) {
+                munmap(g2h(start), host_len);
+                goto fail;
+            }
             host_start += offset - host_offset;
         }
         start = h2g(host_start);
-- 
1.8.2.3

             reply	other threads:[~2013-06-29  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29  9:41 Jürg Billeter [this message]
2013-07-02 14:19 ` [Qemu-devel] [PATCH] linux-user: Do not ignore mmap failure from host Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372498892-23676-1-git-send-email-j@bitron.ch \
    --to=j@bitron.ch \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).