aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-08-22 13:55:55 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-08-28 01:50:02 -0500
commitcc5caf7df4ed5833183121e08c6b6131722137d5 (patch)
treea8dc4bb0f4069de1c22c01e73c034c0b413f5be5
parentb68e45c68667dce43341c94c69126852496ddbaf (diff)
arm-semi: don't leak 1KB user string lock buffer upon TARGET_SYS_OPEN
Always call unlock_user before returning. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit 396bef4b3846bf4e80a2bee38e9a2d8554d0f251) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--arm-semi.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/arm-semi.c b/arm-semi.c
index 88ca9bb1b7..5d2a2d2275 100644
--- a/arm-semi.c
+++ b/arm-semi.c
@@ -194,18 +194,19 @@ uint32_t do_arm_semihosting(CPUARMState *env)
if (!(s = lock_user_string(ARG(0))))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
- if (ARG(1) >= 12)
+ if (ARG(1) >= 12) {
+ unlock_user(s, ARG(0), 0);
return (uint32_t)-1;
+ }
if (strcmp(s, ":tt") == 0) {
- if (ARG(1) < 4)
- return STDIN_FILENO;
- else
- return STDOUT_FILENO;
+ int result_fileno = ARG(1) < 4 ? STDIN_FILENO : STDOUT_FILENO;
+ unlock_user(s, ARG(0), 0);
+ return result_fileno;
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
(int)ARG(2)+1, gdb_open_modeflags[ARG(1)]);
- return env->regs[0];
+ ret = env->regs[0];
} else {
ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644));
}