From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>
Cc: Elvira Khabirova <lineprinter@altlinux.org>,
Eugene Syromyatnikov <esyr@redhat.com>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sh: fix syscall_set_return_value()
Date: Mon, 03 Dec 2018 03:18:04 +0000 [thread overview]
Message-ID: <20181203031804.GD11573@altlinux.org> (raw)
According to documentation in include/asm-generic/syscall.h,
if error argument of syscall_set_return_value() is nonzero,
it is a negated errno.
This change fixes syscall_set_return_value() implementation on sh
to match its own syscall_get_error(), the documentation, and other
architectures where error argument of syscall_set_return_value()
is non-positive.
Fixes: fb4f87a2f048b ("sh: Provide the asm/syscall.h interface, needed by tracehook.")
Fixes: 94e2fb3d3e1f4 ("sh: Provide asm/syscall.h for SH-5.")
Cc: stable@vger.kernel.org # v2.6.28+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
arch/sh/include/asm/syscall_32.h | 5 +----
arch/sh/include/asm/syscall_64.h | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 6e118799831c..5d636a3593d1 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -40,10 +40,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs,
int error, long val)
{
- if (error)
- regs->regs[0] = -error;
- else
- regs->regs[0] = val;
+ regs->regs[0] = error ?: val;
}
static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index 43882580c7f9..799fe72316e2 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -39,10 +39,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs,
int error, long val)
{
- if (error)
- regs->regs[9] = -error;
- else
- regs->regs[9] = val;
+ regs->regs[9] = error ?: val;
}
static inline void syscall_get_arguments(struct task_struct *task,
--
ldv
WARNING: multiple messages have this Message-ID (diff)
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>
Cc: Elvira Khabirova <lineprinter@altlinux.org>,
Eugene Syromyatnikov <esyr@redhat.com>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sh: fix syscall_set_return_value()
Date: Mon, 3 Dec 2018 06:18:04 +0300 [thread overview]
Message-ID: <20181203031804.GD11573@altlinux.org> (raw)
According to documentation in include/asm-generic/syscall.h,
if error argument of syscall_set_return_value() is nonzero,
it is a negated errno.
This change fixes syscall_set_return_value() implementation on sh
to match its own syscall_get_error(), the documentation, and other
architectures where error argument of syscall_set_return_value()
is non-positive.
Fixes: fb4f87a2f048b ("sh: Provide the asm/syscall.h interface, needed by tracehook.")
Fixes: 94e2fb3d3e1f4 ("sh: Provide asm/syscall.h for SH-5.")
Cc: stable@vger.kernel.org # v2.6.28+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
arch/sh/include/asm/syscall_32.h | 5 +----
arch/sh/include/asm/syscall_64.h | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 6e118799831c..5d636a3593d1 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -40,10 +40,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs,
int error, long val)
{
- if (error)
- regs->regs[0] = -error;
- else
- regs->regs[0] = val;
+ regs->regs[0] = error ?: val;
}
static inline void syscall_get_arguments(struct task_struct *task,
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index 43882580c7f9..799fe72316e2 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -39,10 +39,7 @@ static inline void syscall_set_return_value(struct task_struct *task,
struct pt_regs *regs,
int error, long val)
{
- if (error)
- regs->regs[9] = -error;
- else
- regs->regs[9] = val;
+ regs->regs[9] = error ?: val;
}
static inline void syscall_get_arguments(struct task_struct *task,
--
ldv
next reply other threads:[~2018-12-03 3:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 3:18 Dmitry V. Levin [this message]
2018-12-03 3:18 ` [PATCH] sh: fix syscall_set_return_value() Dmitry V. Levin
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=20181203031804.GD11573@altlinux.org \
--to=ldv@altlinux.org \
--cc=dalias@libc.org \
--cc=esyr@redhat.com \
--cc=lineprinter@altlinux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=ysato@users.sourceforge.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.