static int
 setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-              sigset_t *set, struct pt_regs *regs)
+               struct pt_regs *regs)
 {
        int usig = signr_convert(sig);
+       sigset_t *set = ¤t->blocked;
        int ret;
 
+       if (current_thread_info()->status & TS_RESTORE_SIGMASK)
+               set = ¤t->saved_sigmask;
+
        /* Set up the stack frame */
        if (is_ia32) {
                if (ka->sa.sa_flags & SA_SIGINFO)
                return -EFAULT;
        }
 
+       current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
        return ret;
 }
 
 static int
 handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
-             sigset_t *oldset, struct pt_regs *regs)
+               struct pt_regs *regs)
 {
        sigset_t blocked;
        int ret;
            likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
                regs->flags &= ~X86_EFLAGS_TF;
 
-       ret = setup_rt_frame(sig, ka, info, oldset, regs);
+       ret = setup_rt_frame(sig, ka, info, regs);
 
        if (ret)
                return ret;
        struct k_sigaction ka;
        siginfo_t info;
        int signr;
-       sigset_t *oldset;
 
        /*
         * We want the common case to go fast, which is why we may in certain
        if (!user_mode(regs))
                return;
 
-       if (current_thread_info()->status & TS_RESTORE_SIGMASK)
-               oldset = ¤t->saved_sigmask;
-       else
-               oldset = ¤t->blocked;
-
        signr = get_signal_to_deliver(&info, &ka, regs, NULL);
        if (signr > 0) {
                /* Whee! Actually deliver the signal.  */
-               if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
-                       /*
-                        * A signal was successfully delivered; the saved
-                        * sigmask will have been stored in the signal frame,
-                        * and will be restored by sigreturn, so we can simply
-                        * clear the TS_RESTORE_SIGMASK flag.
-                        */
-                       current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
-               }
+               handle_signal(signr, &info, &ka, regs);
                return;
        }
 
         */
        if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
                current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
-               sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
+               set_current_blocked(¤t->saved_sigmask);
        }
 }