Patchwork [1/7] alpha-linux-user: Fix brk error return.

login
register
mail settings
Submitter Richard Henderson
Date May 3, 2010, 5:07 p.m.
Message ID <1272906475-14480-2-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/51513/
State New
Headers show

Comments

Richard Henderson - May 3, 2010, 5:07 p.m.
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 linux-user/syscall.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 17599eb..81e09b3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -718,9 +718,17 @@  abi_long do_brk(abi_ulong new_brk)
                                         PROT_READ|PROT_WRITE,
                                         MAP_ANON|MAP_FIXED|MAP_PRIVATE, 0, 0));
 
-    if (!is_error(mapped_addr))
+#if defined(TARGET_ALPHA)
+    /* We (partially) emulate OSF/1 on Alpha, which requires we
+       return a proper errno, not an unchanged brk value.  */
+    if (is_error(mapped_addr)) {
+        return -TARGET_ENOMEM;
+    }
+#endif
+
+    if (!is_error(mapped_addr)) {
 	target_brk = new_brk;
-    
+    }
     return target_brk;
 }