qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: gang.chen.5i5j@gmail.com
To: riku.voipio@iki.fi, peter.maydell@linaro.org, rth@twiddle.net
Cc: qemu-devel@nongnu.org, xili_gchen_5257@hotmail.com,
	Chen Gang <gang.chen.5i5j@gmail.com>
Subject: [Qemu-devel] [PATCH] linux-user/signal.c: Skip calling unlock_user_struct() when lock_user_struct() failed for target ppc and ppc64
Date: Sun, 13 Sep 2015 11:36:31 +0800	[thread overview]
Message-ID: <1442115391-18775-1-git-send-email-gang.chen.5i5j@gmail.com> (raw)

From: Chen Gang <gang.chen.5i5j@gmail.com>

For target ppc and ppc64, all related funcitons have this issue.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 linux-user/signal.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 0265c46..61f98e7 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -4666,7 +4666,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
     frame_addr = get_sigframe(ka, env, sizeof(*frame));
     if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1))
-        goto sigsegv;
+        goto err;
     sc = &frame->sctx;
 
     __put_user(ka->_sa_handler, &sc->handler);
@@ -4729,6 +4729,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
 sigsegv:
     unlock_user_struct(frame, frame_addr, 1);
+err:
     qemu_log("segfaulting from setup_frame\n");
     force_sig(TARGET_SIGSEGV);
 }
@@ -4748,7 +4749,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
 
     rt_sf_addr = get_sigframe(ka, env, sizeof(*rt_sf));
     if (!lock_user_struct(VERIFY_WRITE, rt_sf, rt_sf_addr, 1))
-        goto sigsegv;
+        goto err;
 
     tswap_siginfo(&rt_sf->info, info);
 
@@ -4825,6 +4826,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
 
 sigsegv:
     unlock_user_struct(rt_sf, rt_sf_addr, 1);
+err:
     qemu_log("segfaulting from setup_rt_frame\n");
     force_sig(TARGET_SIGSEGV);
 
@@ -4840,7 +4842,7 @@ long do_sigreturn(CPUPPCState *env)
 
     sc_addr = env->gpr[1] + SIGNAL_FRAMESIZE;
     if (!lock_user_struct(VERIFY_READ, sc, sc_addr, 1))
-        goto sigsegv;
+        goto err;
 
 #if defined(TARGET_PPC64)
     set.sig[0] = sc->oldmask + ((uint64_t)(sc->_unused[3]) << 32);
@@ -4861,8 +4863,8 @@ long do_sigreturn(CPUPPCState *env)
     return -TARGET_QEMU_ESIGRETURN;
 
 sigsegv:
-    unlock_user_struct(sr, sr_addr, 1);
     unlock_user_struct(sc, sc_addr, 1);
+err:
     qemu_log("segfaulting from do_sigreturn\n");
     force_sig(TARGET_SIGSEGV);
     return 0;
@@ -4905,7 +4907,7 @@ long do_rt_sigreturn(CPUPPCState *env)
 
     rt_sf_addr = env->gpr[1] + SIGNAL_FRAMESIZE + 16;
     if (!lock_user_struct(VERIFY_READ, rt_sf, rt_sf_addr, 1))
-        goto sigsegv;
+        goto err;
 
     if (do_setcontext(&rt_sf->uc, env, 1))
         goto sigsegv;
@@ -4919,6 +4921,7 @@ long do_rt_sigreturn(CPUPPCState *env)
 
 sigsegv:
     unlock_user_struct(rt_sf, rt_sf_addr, 1);
+err:
     qemu_log("segfaulting from do_rt_sigreturn\n");
     force_sig(TARGET_SIGSEGV);
     return 0;
-- 
1.9.3

                 reply	other threads:[~2015-09-13  3:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1442115391-18775-1-git-send-email-gang.chen.5i5j@gmail.com \
    --to=gang.chen.5i5j@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    --cc=xili_gchen_5257@hotmail.com \
    /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).