From patchwork Mon Dec 3 03:18:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 10708571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C122B1579 for ; Mon, 3 Dec 2018 03:18:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A37212A2A4 for ; Mon, 3 Dec 2018 03:18:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 948ED2A452; Mon, 3 Dec 2018 03:18:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72F582A2A4 for ; Mon, 3 Dec 2018 03:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725798AbeLCDSI (ORCPT ); Sun, 2 Dec 2018 22:18:08 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:52362 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725803AbeLCDSH (ORCPT ); Sun, 2 Dec 2018 22:18:07 -0500 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id CBA6172CA65; Mon, 3 Dec 2018 06:18:04 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id B8A277CCEA3; Mon, 3 Dec 2018 06:18:04 +0300 (MSK) Date: Mon, 3 Dec 2018 06:18:04 +0300 From: "Dmitry V. Levin" To: Yoshinori Sato , Rich Felker Cc: Elvira Khabirova , Eugene Syromyatnikov , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sh: fix syscall_set_return_value() Message-ID: <20181203031804.GD11573@altlinux.org> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,